fix(scripts): tolerate an unusable integration.json in the Python helper - #3785
Open
jawwad-ali wants to merge 1 commit into
Open
fix(scripts): tolerate an unusable integration.json in the Python helper#3785jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
`get_invoke_separator()` in scripts/python/common.py indexed the parsed JSON
directly, so two shapes escaped its `except (OSError, json.JSONDecodeError)`
while BOTH of its twins fall back to "." for them:
* A non-mapping top level is valid JSON, so JSONDecodeError never fires and
`state.get(...)` raised AttributeError.
* A non-UTF-8 file raises UnicodeDecodeError -- a ValueError, not an OSError.
Realistic on Windows, where PowerShell 5.1's Out-File/`>` default to UTF-16.
Measured on main -- 6 of 7 inputs crashed the Python helper while bash and
PowerShell 5.1 returned "." for every one:
input python bash pwsh 5.1
{"default_integration":"forge"} '.' . .
[] AttributeError . .
"forge" AttributeError . .
42 AttributeError . .
null AttributeError . .
UTF-16 file UnicodeDecodeError . .
Split the parse out of the lookup, complete the exception tuple, and guard the
top-level shape -- matching `read_feature_json_feature_directory` in this same
module, which already does exactly this. The hyphen-separator feature is
unchanged (regression test included).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jawwad-ali
force-pushed
the
fix/python-helper-integration-json-guards
branch
from
July 28, 2026 14:56
ef83ff3 to
3c1fa08
Compare
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
get_invoke_separator()inscripts/python/common.pyindexes the parsed JSON directly:Two shapes escape that tuple, while both of its twins fall back to
".":[],"forge",42,true,null) is valid JSON, sojson.JSONDecodeErrornever fires and.get()raisesAttributeError.UnicodeDecodeError— aValueError, not anOSError. Realistic on Windows, where PowerShell 5.1'sOut-File/>default to UTF-16.Measured on
main— the Python helper crashed on 6 of 7 inputs while bash and PowerShell 5.1 (tested natively) returned"."for every one:.specify/integration.json{"default_integration":"forge"}'.'..[]..[{"a":1}].."forge"..42..null....The bash twin keeps its
separator="."default when jq → python3 → awk all fail to parse; the PowerShell twin likewise returns".".Fix
Split the parse out of the lookup, complete the exception tuple, and guard the top-level shape — matching
read_feature_json_feature_directoryin this same module, which already does exactly this:So this makes
get_invoke_separatorconsistent both with its cross-language twins and with its neighbour in the same file — it was the odd one out.Verification
TestGetInvokeSeparatorTolerance: 6 parametrized non-mapping shapes + the UTF-16 case → 7 fail before, pass after.test_hyphen_separator_is_still_honoured— regression guard that the real feature (invoke_separator: "-"for e.g. droid/forge) keeps working; passes before and after.tests/test_check_prerequisites_python_parity.py: 19 passed, 8 skipped (the skips are the pre-existing bash/pwsh legs gated off on this machine; baseline was 11 passed, 8 skipped).uvx ruff@0.15.0 check src tests scriptsclean.No behaviour change for a well-formed
integration.json: every path that previously returned a value is byte-for-byte identical.AI-assisted: authored with Claude Code. I measured all three implementations side by side (PowerShell 5.1 natively on Windows) before writing the fix, and matched the guard style already present in the same module.