fix(jsonl): map LifecycleError to invalid_request, not internal_error - #723
Open
Yurii214 wants to merge 1 commit into
Open
fix(jsonl): map LifecycleError to invalid_request, not internal_error#723Yurii214 wants to merge 1 commit into
Yurii214 wants to merge 1 commit into
Conversation
the jsonl/http dispatcher's clean-caller-error catch omitted LifecycleError (lifecycle.py's domain error — a RuntimeError sibling of the already-handled ProposalError), so a caller mistake returned the server-fault code internal_error instead of invalid_request, which clients treat as retryable: a typo'd goal status on kb.set_goal_status, or a self-supersede/-contradict. mcp already maps LifecycleError to ValueError (server.py) and the cli catches it; this brings jsonl/http in line. an unknown goal id already returns invalid_request via ArtifactNotFoundError, so the same method was self-inconsistent — a bad id was a caller error but a bad status a server fault.
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
the jsonl/http dispatcher classifies a
LifecycleErrorasinternal_error(a server-fault code) instead ofinvalid_request(a caller-error code).lifecycle.LifecycleErroris aRuntimeError, and the dispatcher's clean-caller-error catch only covers(ValueError, ProposalError, ArtifactNotFoundError)— soLifecycleErrorfalls through to the bareexcept Exceptionand is logged + returned asinternal_error.concretely,
kb.set_goal_statuswith a bad status:lifecycle.set_goal_statusvalidates the status before the goal lookup and raisesLifecycleError("unknown goal status …").{"code": "internal_error"}, which clients treat as retryable/alertable — for pure bad input.the same method is self-inconsistent: an unknown goal id raises
ArtifactNotFoundError, which is in the tuple → correctlyinvalid_request. so a typo'd id is a clean caller error but a typo'd status is a "server fault".why it's the same class as ProposalError
ProposalErrorisproposals.py's domain error (also aRuntimeError) and is already mapped toinvalid_request.LifecycleErrorislifecycle.py's exact sibling and was simply missing from the tuple. all fourLifecycleErrorraise sites — unknown/no-op goal status, self-supersede, self-contradict — are caller conditions, never internal faults, so mapping the whole class is correct.the other two surfaces already agree: mcp
kb_set_goal_statuswrapsexcept (LifecycleError, ArtifactNotFoundError): raise ValueError(...), and the cli listsLifecycleErrorin_cli_errors.tests/test_goals.pystates the contract directly — "a host sees ValueError, never an internal exception". jsonl/http were the outlier.fix
add
life.LifecycleErrorto the dispatcher'sinvalid_requesttuple (lifeis already imported). one-token change plus a why-comment; no behaviour change for any path that was already correct.test
test_jsonl_set_goal_status_bad_status_is_invalid_requestsendskb.set_goal_statuswithstatus="bogus"and assertserror.code == "invalid_request". it fails on the current code (internal_error) and passes with the fix. (status is validated before the goal lookup, so no goal need exist.)validation
ruff check src tests,mypy src(123 files, no issues), and fullpytest tests/ --ignore=tests/embeddings(2991 passed) all green.