-
Notifications
You must be signed in to change notification settings - Fork 148
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
Visual Studio cannot print ggshield error messages if secrets are too long #170
Comments
Are there any updates on this please? The issue still exists, and unfortunately Visual Studio has made the error message worse - it now just complains about character encodings. The issue especially affects the bundled version of ggshield for Windows due to the use of pyinstaller. Pyinstaller purposefully ignores any environment variables from the user, so the workarounds and possible fixes with users setting To me it seems this issue could be solved nicely with one of the following options:
|
Hello @mherzberg, I have been looking at this issue and here are some feedbacks :
|
Hi @mathieubellon, Many thanks for looking into this issue, and great to hear that "force UTF-8 encoding" will be coming soon! I'm afraid I can't reproduce your fix and screenshot on my end. I tried setting
Do you have any more information on this? I saw the following in their changelog for version 6.0.0, but nothing about that topic since then:
|
@mherzberg Just to explain the delay in my response. There are many more complexities related to this problem than I expected, and I want to have a solid understanding before answering. Thank you for your patience. |
Friendly ping @mherzberg, in case you are not notified automatically about the recent release with the requested bugfix |
Description
When using ggshield as a pre-commit hook in Visual Studio, Visual Studio sometimes cannot print ggshield error message.
This is the error message without the bug:
This is the error message with the bug:
This happens because when the secret is too long, ggshield clips it, replacing the clipped part with an ellipsis character(
…
). Visual Studio fails to decode it and falls back to its generic error message.Workaround
This bug can be avoided by defining the
PYTHONIOENCODING
environment variable toutf-8
before running ggshield. Here is an example of a pre-commit script configured this way:Note that this also affect, in a less annoying way, the command line:
This is also fixed by defining the
PYTHONIOENCODING
environment variable:Possible fixes
I think we can't set the environment variable from within Python, it has to be set before. But it may be possible to change the output encoding of stdout. If this is not possible, the two alternatives are:
...
. This is safe but when clipping both sides it would eat 6 characters instead of 2.PYTHONIOENCODING
environment variable.The text was updated successfully, but these errors were encountered: