Repository navigation
fix(settings): answer 404 for unknown connection-test run ids - #2841
Open
qiuqianyi66 wants to merge 1 commit into
Open
qiuqianyi66 wants to merge 1 commit into
qiuqianyi66 wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
What
A connection-test run id the runner no longer knows now answers 404
Unknown test runinstead of a 500 with a rawKeyError.ConfigTestRunner.get()returnsNonefor an unknown id instead of raising (dict.get), andcancel()reportsFalsefor it — the same shape the memory run manager already uses.GET /api/settings/tests/{service}/{run_id}/eventsreturns 404 before starting the stream when the run is gone.POST /api/settings/tests/{service}/{run_id}/cancelreturns 404 when there was nothing to cancel.Fixes #2840.
Why
Runs live in memory (
ConfigTestRunner._runs). A server restart mid-test, or a Settings page reconnecting with an id from the earlier process, asks for a run that is not there. Before:After:
Streaming and cancellation for a live run are unchanged. This mirrors
GET /api/memory/runs/{run_id}, which already answers404 unknown run_idvia aNonelookup.Tests
Two new files:
tests/services/config/test_test_runner_lookup.py— unknown id →None; started run → same object; cancel unknown →False; cancel live → markscancelledand returnsTrue.tests/api/test_settings_test_run_lookup.py— the events endpoint and the cancel endpoint raiseHTTPException(404, "Unknown test run")for an unknown id, and a known run still cancels.Evidence:
KeyErrorpath) and pass with the change (7 passed);pytest tests/api/test_settings_router.py tests/api/test_settings_service_preview.py tests/services/config -q: 448 passed, plus 6 failures that fail identically on the parent commit in this clone (they need a runtimedata/user/settings/agents.yamlthat is not part of the repo) and are untouched here;pre-commit run --files ...on the four files: all hooks pass (ruff, ruff-format, detect-secrets, bandit, mypy).