Repository navigation
Reject tokens that cannot be sent, so they never appear in an exception - #159
Open
JoshuaF-ML wants to merge 1 commit into
Open
JoshuaF-ML wants to merge 1 commit into
JoshuaF-ML wants to merge 1 commit into
Conversation
A non-ASCII token passed token_value and then raised UnicodeEncodeError while the header was encoded. That error holds the whole header, so its repr exposed the bearer token. Accept only visible ASCII and raise ValueError at construction. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
token_valuerejects empty tokens and whitespace but accepts non-ASCII characters, such as a byte order mark left by a token file (str.strip()keeps it) or a zero-width space from copy and paste.The token then fails while the
Authorizationheader is encoded:export_reviews(sync and async) andmcp.list_organizations(sync) raise a rawUnicodeEncodeError. Itsrepr()and.objectholdBearer <token>.list_repositories(sync) raisesurn:proofline:sdk:invalid-response, which does not point at the token, and keeps the encoding error in its context chain.The standard traceback text did not show the token. Anything that logs
repr(error)or inspects the exception would. The README says the clients redact the token from diagnostic output.Approach
token_valuenow accepts only visible ASCII (!to~) and raisesValueError, without the token, when the client is constructed. One check covers every request path. It also refuses control characters and DEL; DEL previously reached the server in my local test.Reproduce
Before:
After:
Verification
On Windows 11 with Python 3.12:
PROOFLINE_TOKEN, sync and async). All 20 fail without the fix and pass with it.ruff check .,ruff format --check .andmypy prooflinepass.pytest -q: 254 tests. The latest run had 252 passed and 2 failed, and an earlier run with this change passed all 254. Both failures are thesynccases oftest_body_stream_deadline_does_not_turn_authority_into_timeout, which also failed on the untouched clone and is intermittent on this machine.scripts/check.py.I used an AI coding agent (Claude Code) to find, fix and test this.