fix: type guard in mask_api_key, remove dead skill ref, explicit utf-8 encoding - #29608
Closed
annguyenNous wants to merge 1 commit into
Closed
fix: type guard in mask_api_key, remove dead skill ref, explicit utf-8 encoding#29608annguyenNous wants to merge 1 commit into
annguyenNous wants to merge 1 commit into
Conversation
…8 encoding - Add isinstance(key, str) guard in _mask_api_key_for_logs() before calling len(). The type hint is Any — a non-string truthy value (e.g. int) would crash with TypeError on len(). Now returns repr(key)[:12] for non-string non-callable values. - Remove hard-coded skills=['avoid-ai-writing'] in kanban_swarm.py. The skill was removed in v0.14.0 but the reference remained, causing crash loops. Changed to empty list. - Add explicit encoding='utf-8' to all .encode() calls in security-sensitive code (HMAC, SHA256 hashing): * hermes_cli/webhook.py: HMAC signature + payload encoding * hermes_cli/auth.py: Z.AI key hash + MiniMax PKCE challenge * gateway/run.py: API key fingerprint + session fingerprint
Collaborator
Contributor
|
Thanks for the defensive cleanup. The type-guard idea remains relevant on current main, but this needs a narrow revision before salvage. Problems
Suggested changes
Automated hermes-sweeper review. |
This was referenced Jul 29, 2026
Contributor
|
Closing — the sites this PR touched are already explicit-encoding on current main (PLW1514 ruff gate, enabled and enforced in lint CI). The class can't regress. Thanks for the sweep work. |
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.
Summary
Fixes 3 classes of bugs:
1. Type guard in
_mask_api_key_for_logs(run_agent.py)The method accepts
key: Anybut callslen(key)without checking ifkeyis a string. A non-string truthy value (e.g.int) would crash withTypeError: object of type 'int' has no len().Fix: Add
if not isinstance(key, str): return repr(key)[:12]after the callable/None checks.2. Dead skill reference in kanban_swarm.py
skills=["avoid-ai-writing"]references a skill that was removed in v0.14.0, causing crash loops when synthesizer tries to load it.Fix: Changed to
skills=[].3. Explicit
encoding="utf-8"in security-sensitive.encode()calls~100
.encode()calls across the codebase rely on the default UTF-8 encoding. While correct in Python 3, explicit encoding is best practice for security-sensitive code (HMAC, SHA256 hashing) to prevent cross-platform surprises.Fix: Added
encoding="utf-8"to:hermes_cli/webhook.py: HMAC signature computation + payload encodinghermes_cli/auth.py: Z.AI key hash (2 locations) + MiniMax PKCE challengegateway/run.py: API key fingerprint + session fingerprintTest Plan
py_compile