Skip to content

Fix TypeError crashes for unknown agent and command names#18592

Open
Haohao-end wants to merge 2 commits intoanomalyco:devfrom
Haohao-end:fix/18310-agent-command-typed-error
Open

Fix TypeError crashes for unknown agent and command names#18592
Haohao-end wants to merge 2 commits intoanomalyco:devfrom
Haohao-end:fix/18310-agent-command-typed-error

Conversation

@Haohao-end
Copy link
Copy Markdown

Issue for this PR

Closes #18310

Type of change

  • Bug fix
  • Refactor / code improvement
  • New feature
  • Documentation

What does this PR do?

This fixes the unknown agent / unknown command TypeError path in session prompt flows.

Previously, Agent.get() / Command.get() could return undefined, and some must-exist prompt paths later dereferenced those values and crashed with generic TypeErrors.

This PR keeps the existing nullable get() behavior, adds typed not-found errors plus must() 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:

  • unknown prompt agent
  • unknown command

I also verified the affected prompt paths now fail with typed not-found errors instead of raw TypeErrors.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title Fix TypeError crashes for unknown agent and command names doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

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"
#18280

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin system: undefined agent/command crashes, silent prompt_async errors, config hook isolation, hook timing, startup ordering

1 participant