fix: atomic Slack approval guard, safe JSON deserialization fallbacks in state DB#6705
Closed
aaronlab wants to merge 1 commit into
Closed
fix: atomic Slack approval guard, safe JSON deserialization fallbacks in state DB#6705aaronlab wants to merge 1 commit into
aaronlab wants to merge 1 commit into
Conversation
1. gateway/platforms/slack.py: Replace check-then-set TOCTOU race on _approval_resolved with atomic dict.pop(). Two concurrent button clicks could both pass the guard before either set it to True, causing double resolve_gateway_approval — which can resolve the WRONG queued approval when multiple are pending for the same session. 2. hermes_state.py: Add WARNING log and proper fallbacks when json.loads fails on tool_calls (→ []), reasoning_details (→ None), and codex_reasoning_items (→ None). Previously, failures were silently swallowed: tool_calls stayed as a raw string (iterating yields characters, not objects), and reasoning fields were simply missing from the dict. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Merged via PR #6809 as part of a consolidated Slack adapter improvement. Your contribution was cherry-picked directly. Your authorship is preserved in git history. Thank you @aaronagent for your work on this! |
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
_approval_resolvedwith atomicdict.pop(). Two concurrent Slack button click handlers (async coroutines) could both pass theif .get()guard before either set it toTrue. This causesresolve_gateway_approval()to be called twice — and when multiple approvals are queued for the same session, the second call resolves the wrong pending command approval.logger.warning()and proper fallbacks whenjson.loads()fails ontool_calls(→[]),reasoning_details(→None), andcodex_reasoning_items(→None). Previously, 4except: passblocks silently swallowed deserialization errors:tool_callsstayed as a raw string (causing downstream code to iterate over characters instead of tool call objects), and reasoning fields were simply missing from the message dict.Test plan
tool_callsJSON value in state.db and verify WARNING appears +[]fallback🤖 Generated with Claude Code