fix: use .get() for file_structure keys to prevent KeyError in workdir extras#1476
Open
wgnrai wants to merge 1 commit intoagent0ai:developmentfrom
Open
fix: use .get() for file_structure keys to prevent KeyError in workdir extras#1476wgnrai wants to merge 1 commit intoagent0ai:developmentfrom
wgnrai wants to merge 1 commit intoagent0ai:developmentfrom
Conversation
When a project.json file_structure section is missing the gitignore key,
the extension crashes with KeyError, which can halt the agent entirely.
Fix uses .get() with sensible defaults for all file_structure accesses:
- enabled -> .get("enabled", False)
- max_depth -> .get("max_depth", 0)
- gitignore -> .get("gitignore", "")
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
When a project's
project.jsonhas afile_structuresection that is missing thegitignorekey, the_75_include_workdir_extrasextension crashes with aKeyErrorduringprepare_prompt(). This kills the agent's monologue loop silently, causing the entire agent to halt with no error output.This is especially problematic because
project.jsonfiles created without agitignorefield (or with partialfile_structureconfigs) will crash every agent loop iteration.Fix
Replace direct dict access with
.get()and sensible defaults for allfile_structurekeys:enabled->.get("enabled", False)max_depth->.get("max_depth", 0)gitignore->.get("gitignore", "")Files Changed
extensions/python/message_loop_prompts_after/_75_include_workdir_extras.py- 3 linesImpact
This bug can cause agents to silently freeze/halt when a project is missing the
gitignorekey in its file_structure config. The fix ensures graceful degradation with defaults.