Conversation
The gh sub-issue list command returns JSON in the format:
{"subIssues": [{"number": 586}]}
Previously, the script incorrectly tried to index directly into the JSON
response as if it were an array, causing KeyError: 0.
This fix:
- Correctly extracts the "subIssues" wrapper from JSON response
- Handles None/null cases gracefully with .get() and safe checks
- Adds TypeError to exception handling for robustness
- Applies fix to both parent and children relationship parsing
Fixes #608
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a crash in the scripts/gh-milestones/prep-next.py script caused by incorrect JSON parsing. The script was attempting to directly index the JSON response from gh sub-issue list as an array, when it actually returns a wrapped object with a subIssues field.
Key Changes:
- Corrects JSON parsing to extract the
subIssueswrapper object instead of treating response as a direct array - Adds defensive null checks and improved error handling with
TypeErrorandKeyErrorexceptions - Applies consistent fix to both parent and children relationship parsing
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…andling - Rename sub_issues → parent_issues in parent parsing for clarity - Rename sub_issues → child_issues in children parsing for clarity - Remove redundant len() > 0 check (more Pythonic) - Add explanatory comment to parent parsing except clause - Add error logging to children parsing except clause Addresses Copilot review comments in PR #609
5 tasks
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 the
scripts/gh-milestones/prep-next.pyscript crash when building issue hierarchy. The script was incorrectly parsing the JSON output fromgh sub-issue list, which returns data in the format{"subIssues": [...]}rather than a direct array.Changes
subIssueswrapper from JSON responseTypeErrorto exception handling, use.get()for safe accessparents_data/children_datais not None before accessingRoot Cause
The
gh sub-issue listcommand returns:{ "subIssues": [ {"number": 586} ] }But the code was trying to index directly:
Fix
Testing
Verified the fix by running:
Result: ✅ Successfully completed without errors, correctly identified next issue #586
Related Issues
Fixes #608
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com