Fix TypeError crashes for unknown agent and command names#18592
Fix TypeError crashes for unknown agent and command names#18592Haohao-end wants to merge 2 commits intoanomalyco:devfrom
Conversation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: I found a potential related PR: PR #18280 - "fix: improve plugin system robustness — agent/command resolution, async errors, hook timing, two-phase init" Why it might be related: This PR also addresses agent/command resolution issues and robustness improvements in the plugin system, which overlaps with the scope of PR #18592's handling of unknown agent and command names. Both appear to be working on similar resolution and error handling paths. However, note that PR #18592 is the current PR you're checking, and it specifically closes issue #18310. The other PR (#18280) may be addressing different aspects of the same system or related issues. |
Issue for this PR
Closes #18310
Type of change
What does this PR do?
This fixes the unknown agent / unknown command TypeError path in session prompt flows.
Previously,
Agent.get()/Command.get()could returnundefined, and some must-exist prompt paths later dereferenced those values and crashed with genericTypeErrors.This PR keeps the existing nullable
get()behavior, adds typed not-found errors plusmust()helpers, and switches only the required prompt paths to use them. It also keeps intentionally nullable paths unchanged.How did you verify your code works?
I added regression tests for:
I also verified the affected prompt paths now fail with typed not-found errors instead of raw
TypeErrors.Screenshots / recordings
N/A
Checklist