Repository navigation
fix: publish session.error event for invalid model selection - #8451
Merged
rekram1-node merged 1 commit intoFeb 9, 2026
Merged
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
When sending a message via the API with an invalid provider/model ID, the error was being thrown inside the loop() function but never surfaced to API consumers. The HTTP response had already returned 200 and no session.error event was published. This adds error handling around Provider.getModel() in loop() to publish a session.error event before re-throwing, matching the existing pattern in the command() function.
surma
force-pushed
the
surma/publish-invalid-model-errors
branch
from
January 14, 2026 16:41
60684ad to
b6f060f
Compare
opencode-agent
Bot
force-pushed
the
dev
branch
from
January 30, 2026 14:32
00637c0 to
71e0ba2
Compare
thdxr
force-pushed
the
dev
branch
3 times, most recently
from
January 30, 2026 14:37
f1ae801 to
08fa7f7
Compare
Collaborator
|
/review |
Contributor
|
lgtm |
Colin4k1024
pushed a commit
to Colin4k1024/opencode
that referenced
this pull request
Feb 10, 2026
BryceRyan
pushed a commit
to BryceRyan/opencode
that referenced
this pull request
Feb 10, 2026
3 tasks
relaxkeren
pushed a commit
to relaxkeren/opencode
that referenced
this pull request
Feb 15, 2026
schneiderlo
pushed a commit
to schneiderlo/opencode
that referenced
this pull request
Feb 17, 2026
Rwanbt
pushed a commit
to Rwanbt/unifia
that referenced
this pull request
May 5, 2026
AIALRA-0
pushed a commit
to AIALRA-0/opencode-turn-engine
that referenced
this pull request
Jun 10, 2026
Rwanbt
pushed a commit
to Rwanbt/unifia
that referenced
this pull request
Jun 14, 2026
MarsQiu007
referenced
this pull request
in MarsQiu007/openNovel
Jul 31, 2026
meSingh
pushed a commit
to meSingh/opencode
that referenced
this pull request
Sep 6, 2026
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.
Fix: Publish session.error event for invalid model selection
Problem
When sending a message via the API with an invalid provider or model ID, the error was silently swallowed. API consumers had no way to know something went wrong.
What happened:
/session/{id}/messagewith{ model: { providerID: "invalid", ... } }busy→idlewith no error indicationsession.errorevent is published to/eventRoot cause: The
Provider.getModel()call happens insideloop()after the HTTP response has already started streaming. When it throwsModelNotFoundError, the error propagates up but is never converted to asession.errorevent.Solution
Added error handling around
Provider.getModel()inloop()to publish asession.errorevent before re-throwing. This matches the existing pattern used in thecommand()function.After this fix:
Changes
packages/opencode/src/session/prompt.ts: WrapProvider.getModel()in try-catch, publishsession.erroronModelNotFoundErrorFixes #8460