Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

click.echo fails when passed bytes #373

Closed
jhall1-godaddy opened this issue Jul 22, 2022 · 0 comments · Fixed by #372
Closed

click.echo fails when passed bytes #373

jhall1-godaddy opened this issue Jul 22, 2022 · 0 comments · Fixed by #372
Labels
bug Something isn't working

Comments

@jhall1-godaddy
Copy link
Contributor

🐛 Bug Report

There appears to be some bug in click, where it is unable to print bytes even thought it is typed as accepting bytes.
We explicitly convert a scanner to bytes before echoing it - which causes a bug in the update-signatures command on some configs - I havent found the exact cause of the issue however.

To Reproduce

Reproduction is unreliable, I've been able to reproduce by copying an internal config that was having this issue.
This is resolved by passing a string instead of bytes to click.echo

Expected Behavior

The update signatures command will run.

Actual result

$ python -m tartufo update-signatures .
Traceback (most recent call last):
  File "/Users/jonx/.pyenv/versions/3.10.1/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/jonx/.pyenv/versions/3.10.1/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/jonx/projects/tartufo/tartufo/__main__.py", line 5, in <module>
    cli.main()  # pylint: disable=no-value-for-parameter
  File "/Users/jonx/projects/tartufo/.venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/jonx/projects/tartufo/.venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/jonx/projects/tartufo/.venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/jonx/projects/tartufo/.venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/jonx/projects/tartufo/.venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/jonx/projects/tartufo/.venv/lib/python3.10/site-packages/click/decorators.py", line 38, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/Users/jonx/projects/tartufo/.venv/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/jonx/projects/tartufo/tartufo/commands/update_signatures.py", line 245, in main
    scanner, stderr = scan_local_repo(
  File "/Users/jonx/projects/tartufo/tartufo/commands/update_signatures.py", line 71, in scan_local_repo
    util.process_issues(repo_path, scanner, options)
  File "/Users/jonx/projects/tartufo/tartufo/util.py", line 265, in process_issues
    echo_result(options, scan, repo_path, output_dir)
  File "/Users/jonx/projects/tartufo/tartufo/util.py", line 107, in echo_result
    click.echo(bytes(issue))
  File "/Users/jonx/projects/tartufo/.venv/lib/python3.10/site-packages/click/utils.py", line 299, in echo
    file.write(out)  # type: ignore
TypeError: string argument expected, got 'bytes'

Environment

Tartufo version 3.2.1
MacOS Monterey 12.4
Python 3.10.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant