Skip to content

fix(agent-server): map profile-store errors in scoped secrets list - #5898

Merged
enyst merged 2 commits into
mainfrom
claude/umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors
Oct 17, 2026
Merged

enyst merged 2 commits into
mainfrom
claude/umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors

Conversation

@enyst

@enyst enyst commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

HUMAN:
This PR proposes a fix for a bug uncovered during the first full agentic run of verify-agent-server.


AGENT:

I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.

Why

GET /api/settings/secrets?agent_profile_id=<id> answered an unhandled 500 when the named agent profile's file no longer validates, and a 500 after the 30 s lock timeout when another process holds the agent-profile store lock. The agent-profile routes answer the same two conditions with 400 (Failed to load profile ...) and 503 (Profile store is busy. Please retry.). list_secrets called AgentProfileStore.name_for_id/load outside store_errors().

Summary

  • list_secrets now reads the scoping profile inside store_errors(), so the route answers 400 / 503 like the agent-profile routes; unknown ids still answer 404 and valid ids still scope the list.
  • Two unit tests in tests/agent_server/test_settings_router.py (unloadable profile -> 400, lock timeout -> 503).
  • Feature map F18.secret-scope-profile-errors: # bug markers removed, prose and the Gotchas line rewritten as expected behaviour, and the first bullet now declares Requires: F18.secret-put-list-get (it reads the QA_F18_TOKEN secret that bullet creates, so --only failed in arrange instead of reaching the marker).

Issue Number

Fixes #5883

How to Test

  • uv run pytest tests/agent_server/test_settings_router.py tests/agent_server/test_agent_profiles_router.py: 166 passed. The two new tests fail on main (unhandled ValueError: Failed to load profile ... / TimeoutError) and pass here.
  • Map proof (with the Requires: line added, markers still in place):
    • control-agent-server map run --file F18 --only F18.secret-scope-profile-errors --fresh --repeat 2 --checkout <main checkout>: both bullets xfail twice.
    • same command launching this branch: both bullets xpass twice.
    • after dropping the markers: map check ok, map run --only F18.secret-scope-profile-errors --fresh: pass 4 / fail 0.
  • uv run pre-commit run --files <changed files>: all passed.

Video/Screenshots

n/a

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

#5851 edits two docstrings in the same settings_router.py and the neighbouring F18.secret-name-contract Gotchas bullet; this PR only touches list_secrets and the secret-scope-profile-errors Gotchas bullet, which sits right below it, so a merge of one may need a trivial rebase of the other. A held store lock still stalls the whole server for 30 s, which is #5632 and out of scope here.


🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)

• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python-slim amd64, arm64 python-node-runtime Link
python-minimal amd64, arm64 python-node-runtime Link
python amd64, arm64 python-node-runtime Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:cce4211-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-cce4211-python \
  ghcr.io/openhands/agent-server:cce4211-python

All tags pushed for this build

ghcr.io/openhands/agent-server:cce4211-golang-amd64
ghcr.io/openhands/agent-server:cce42117e77fa59ba8fd3d1432ac5b193ea434db-golang-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors-golang-amd64
ghcr.io/openhands/agent-server:cce4211-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:cce4211-golang-arm64
ghcr.io/openhands/agent-server:cce42117e77fa59ba8fd3d1432ac5b193ea434db-golang-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors-golang-arm64
ghcr.io/openhands/agent-server:cce4211-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:cce4211-java-amd64
ghcr.io/openhands/agent-server:cce42117e77fa59ba8fd3d1432ac5b193ea434db-java-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors-java-amd64
ghcr.io/openhands/agent-server:cce4211-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:cce4211-java-arm64
ghcr.io/openhands/agent-server:cce42117e77fa59ba8fd3d1432ac5b193ea434db-java-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors-java-arm64
ghcr.io/openhands/agent-server:cce4211-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:cce4211-python-amd64
ghcr.io/openhands/agent-server:cce42117e77fa59ba8fd3d1432ac5b193ea434db-python-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors-python-amd64
ghcr.io/openhands/agent-server:cce4211-python-node-runtime-amd64
ghcr.io/openhands/agent-server:cce4211-python-arm64
ghcr.io/openhands/agent-server:cce42117e77fa59ba8fd3d1432ac5b193ea434db-python-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors-python-arm64
ghcr.io/openhands/agent-server:cce4211-python-node-runtime-arm64
ghcr.io/openhands/agent-server:cce4211-python-minimal-amd64
ghcr.io/openhands/agent-server:cce42117e77fa59ba8fd3d1432ac5b193ea434db-python-minimal-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors-python-minimal-amd64
ghcr.io/openhands/agent-server:cce4211-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:cce4211-python-minimal-arm64
ghcr.io/openhands/agent-server:cce42117e77fa59ba8fd3d1432ac5b193ea434db-python-minimal-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors-python-minimal-arm64
ghcr.io/openhands/agent-server:cce4211-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:cce4211-python-slim-amd64
ghcr.io/openhands/agent-server:cce42117e77fa59ba8fd3d1432ac5b193ea434db-python-slim-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors-python-slim-amd64
ghcr.io/openhands/agent-server:cce4211-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:cce4211-python-slim-arm64
ghcr.io/openhands/agent-server:cce42117e77fa59ba8fd3d1432ac5b193ea434db-python-slim-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors-python-slim-arm64
ghcr.io/openhands/agent-server:cce4211-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:cce4211-golang
ghcr.io/openhands/agent-server:cce42117e77fa59ba8fd3d1432ac5b193ea434db-golang
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors-golang
ghcr.io/openhands/agent-server:cce4211-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:cce4211-java
ghcr.io/openhands/agent-server:cce42117e77fa59ba8fd3d1432ac5b193ea434db-java
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors-java
ghcr.io/openhands/agent-server:cce4211-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:cce4211-python-minimal
ghcr.io/openhands/agent-server:cce42117e77fa59ba8fd3d1432ac5b193ea434db-python-minimal
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors-python-minimal
ghcr.io/openhands/agent-server:cce4211-python-node-runtime-minimal
ghcr.io/openhands/agent-server:cce4211-python-slim
ghcr.io/openhands/agent-server:cce42117e77fa59ba8fd3d1432ac5b193ea434db-python-slim
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors-python-slim
ghcr.io/openhands/agent-server:cce4211-python-node-runtime-slim
ghcr.io/openhands/agent-server:cce4211-python
ghcr.io/openhands/agent-server:cce42117e77fa59ba8fd3d1432ac5b193ea434db-python
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors-python
ghcr.io/openhands/agent-server:cce4211-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., cce4211-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., cce4211-python-amd64) are also available if needed

GET /api/settings/secrets?agent_profile_id= read the agent profile outside
store_errors(), so a profile file that no longer validates answered an
unhandled 500 (agent-profile routes: 400) and a lock timeout answered 500
(agent-profile routes: 503 'Profile store is busy'). Wrap the lookup in
store_errors(), add unit tests, and drop the F18 known-bug markers (the
first bullet now also declares its dependency on F18.secret-put-list-get).

Fixes #5883

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014MKndVj7XWvRQmvW9w2bDg
@enyst enyst self-assigned this Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-agent-server/openhands/agent_server
   settings_router.py198697%224, 563, 565–566, 604, 609
TOTAL503832006960% 

@enyst
enyst marked this pull request as ready for review October 14, 2026 01:29
@enyst
enyst requested a review from all-hands-bot October 14, 2026 01:36

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was posted by an AI agent (OpenHands).

Scope

This change is correctly placed: it fixes an Agent Server REST route (GET /api/settings/secrets), which this repository owns. No cross-repo move is warranted.

Findings

No material findings.

  • Root cause and fix. list_secrets (openhands-agent-server/openhands/agent_server/settings_router.py:467-475) previously called AgentProfileStore.name_for_id / load outside store_errors(), so ValueError (unloadable profile) and TimeoutError (held lock) surfaced as an unhandled 500. Wrapping the reads in with store_errors(): routes them through the same mapping the agent-profile routes use (_secrets_exposure.py:127): 400 with the Failed to load profile ... detail, 503 Profile store is busy. Please retry.. This matches the linked issue #5883 root cause exactly.
  • Non-regression of adjacent behavior. The HTTPException(404, "Agent profile not found") for an unknown id is raised inside the try but is not caught by store_errors() (it is not a ValueError/TimeoutError), so the 404 is preserved. ProviderConnectionNotFound (a ValueError subclass) is handled before the generic arm; AgentProfileStore.load does not raise it, so no behavior is altered. Scoping of the returned names and the secret_refs is None unscoped path are unchanged.
  • Tests. test_list_secrets_unloadable_agent_profile_is_400 and test_list_secrets_busy_agent_profile_store_is_503 exercise the two new paths; the existing 404 (test_list_secrets_rejects_unknown_agent_profile) and success-scope (test_list_secrets_scoped_by_agent_profile) cases are retained. I ran uv run pytest tests/agent_server/test_settings_router.py tests/agent_server/test_agent_profiles_router.py on this head: 166 passed. The 503 test asserts response.json()["exception"] == "503: Profile store is busy. Please retry.", which matches the _http_exception_handler 5xx shape in api.py.
  • Feature map. Removing the two # bug markers and rewriting the prose to expected behavior is consistent with the known-bug contract; map check --file F18 reports ok: true. Adding Requires: F18.secret-put-list-get to the first bullet is correct — it reads QA_F18_TOKEN, created by that earlier recipe.
  • CI. All check runs for a2d4e8bb8d487d808471ad93590afd2693ae2213 are green (agent-server-tests, coverage-report, build-binary-and-test, etc.).

The PR notes a possible trivial rebase conflict with #5851 (adjacent docstrings/Gotchas bullet); that is a merge-mechanics concern, not a defect in this head. The held-lock 30 s stall is #5632 and explicitly out of scope.

✅ APPROVED

…e-profile-errors

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S978x74H7Drsnw7bzoGWc8
@enyst
enyst enabled auto-merge (squash) October 17, 2026 01:04
@enyst
enyst merged commit 1396fa7 into main Oct 17, 2026
43 checks passed
@enyst
enyst deleted the claude/umbrella-bug-fixes-tgz9ai-secret-scope-profile-errors branch October 17, 2026 01:04
@github-actions github-actions Bot mentioned this pull request Oct 19, 2026
1 of 7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants