Skip to content

fix(agent-server): resolve provider connection in profile validate - #5755

Merged
enyst merged 1 commit into
mainfrom
claude/umbrella-bug-fixes-tgz9ai-validate-linked-draft
Oct 22, 2026
Merged

enyst merged 1 commit into
mainfrom
claude/umbrella-bug-fixes-tgz9ai-validate-linked-draft

Conversation

@enyst

@enyst enyst commented Oct 13, 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:

Why

Profile validation checked a provider-linked draft without the saved connection’s key, reporting an authentication failure even though activating the same draft worked.

Summary

 POST /api/profiles/{name}/validate
   decrypt posted LLM secrets
   resolve_provider_connection
     no link       → posted LLM unchanged
     existing link → connection key + base URL → model preflight
     missing link  → 422 naming connection ID; no model call

Resolve the provider connection before validation using the same store error mapping as activation and model switching. Clients can validate a linked draft without possessing or resending its key.

Source: profiles_router.py.

Issue Number

Fixes #5644

How to Test

Previously recorded verification
  • uv run pytest tests/agent_server/test_profiles_router.py: 111 passed. Both new tests failed on main before the fix.
  • uv run pre-commit run --files <changed files>: all passed (ruff, pycodestyle, pyright, import rules).
  • Map proof, with a real DeepSeek key behind the connection:
    • control-agent-server map run --file F23 --only F23.validate-linked-draft --fresh --repeat 2 --checkout <main checkout at dfd8fe8> reported xfail in both attempts.
    • The same command against this branch's checkout reported xpass in both attempts.
    • With the marker removed, control-agent-server map check is ok (34 files, 935 ids, no problems), and map run --file F23 --only F23.validate-linked-draft --fresh reports pass.

Video/Screenshots

n/a

Type

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

Notes

The implemented dangling-link policy is HTTP 422, rather than 200 with valid: false, consistent with activation and switch_llm. The detail contains the connection ID and fixed text, not credentials. Request and response models remain unchanged. Original triage: #5644.

Visual explanation by Codex using HumanLayer show-me.


🐳 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:217927e-python

Run

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

All tags pushed for this build

ghcr.io/openhands/agent-server:217927e-golang-amd64
ghcr.io/openhands/agent-server:217927e98b8305d51f6895d3e9a48f674d8f3954-golang-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-validate-linked-draft-golang-amd64
ghcr.io/openhands/agent-server:217927e-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:217927e-golang-arm64
ghcr.io/openhands/agent-server:217927e98b8305d51f6895d3e9a48f674d8f3954-golang-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-validate-linked-draft-golang-arm64
ghcr.io/openhands/agent-server:217927e-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:217927e-java-amd64
ghcr.io/openhands/agent-server:217927e98b8305d51f6895d3e9a48f674d8f3954-java-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-validate-linked-draft-java-amd64
ghcr.io/openhands/agent-server:217927e-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:217927e-java-arm64
ghcr.io/openhands/agent-server:217927e98b8305d51f6895d3e9a48f674d8f3954-java-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-validate-linked-draft-java-arm64
ghcr.io/openhands/agent-server:217927e-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:217927e-python-amd64
ghcr.io/openhands/agent-server:217927e98b8305d51f6895d3e9a48f674d8f3954-python-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-validate-linked-draft-python-amd64
ghcr.io/openhands/agent-server:217927e-python-node-runtime-amd64
ghcr.io/openhands/agent-server:217927e-python-arm64
ghcr.io/openhands/agent-server:217927e98b8305d51f6895d3e9a48f674d8f3954-python-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-validate-linked-draft-python-arm64
ghcr.io/openhands/agent-server:217927e-python-node-runtime-arm64
ghcr.io/openhands/agent-server:217927e-python-minimal-amd64
ghcr.io/openhands/agent-server:217927e98b8305d51f6895d3e9a48f674d8f3954-python-minimal-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-validate-linked-draft-python-minimal-amd64
ghcr.io/openhands/agent-server:217927e-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:217927e-python-minimal-arm64
ghcr.io/openhands/agent-server:217927e98b8305d51f6895d3e9a48f674d8f3954-python-minimal-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-validate-linked-draft-python-minimal-arm64
ghcr.io/openhands/agent-server:217927e-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:217927e-python-slim-amd64
ghcr.io/openhands/agent-server:217927e98b8305d51f6895d3e9a48f674d8f3954-python-slim-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-validate-linked-draft-python-slim-amd64
ghcr.io/openhands/agent-server:217927e-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:217927e-python-slim-arm64
ghcr.io/openhands/agent-server:217927e98b8305d51f6895d3e9a48f674d8f3954-python-slim-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-validate-linked-draft-python-slim-arm64
ghcr.io/openhands/agent-server:217927e-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:217927e-golang
ghcr.io/openhands/agent-server:217927e98b8305d51f6895d3e9a48f674d8f3954-golang
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-validate-linked-draft-golang
ghcr.io/openhands/agent-server:217927e-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:217927e-java
ghcr.io/openhands/agent-server:217927e98b8305d51f6895d3e9a48f674d8f3954-java
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-validate-linked-draft-java
ghcr.io/openhands/agent-server:217927e-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:217927e-python-minimal
ghcr.io/openhands/agent-server:217927e98b8305d51f6895d3e9a48f674d8f3954-python-minimal
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-validate-linked-draft-python-minimal
ghcr.io/openhands/agent-server:217927e-python-node-runtime-minimal
ghcr.io/openhands/agent-server:217927e-python-slim
ghcr.io/openhands/agent-server:217927e98b8305d51f6895d3e9a48f674d8f3954-python-slim
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-validate-linked-draft-python-slim
ghcr.io/openhands/agent-server:217927e-python-node-runtime-slim
ghcr.io/openhands/agent-server:217927e-python
ghcr.io/openhands/agent-server:217927e98b8305d51f6895d3e9a48f674d8f3954-python
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-validate-linked-draft-python
ghcr.io/openhands/agent-server:217927e-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., 217927e-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., 217927e-python-amd64) are also available if needed

POST /api/profiles/{name}/validate sent the posted LLM unchanged, so a
draft linked to a provider connection without an inline key was checked
keyless and reported valid:false. Resolve provider_connection_id before
the pre-flight, as activation and switch_llm do; a dangling link is a
422 naming the missing connection.

Drop the F23.validate-linked-draft known-bug marker from the
verify-agent-server map.

Fixes #5644

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 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-agent-server/openhands/agent_server
   profiles_router.py202697%509–514
TOTAL497311987060% 

@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).

Review: PR #5755 — resolve provider connection in profile validate

Verdict: clean, well-scoped fix that mirrors the established resolution pattern. No material findings.

Scope

Belongs in this repository. The change touches the agent-server REST API (openhands-agent-server/openhands/agent_server/profiles_router.py) plus the verify-agent-server feature map and router tests, all owned here per the root AGENTS.md cross-repository boundaries. It is a backend behavior fix, not a client or another-repo concern.

Correctness

  • validate_profile now calls get_llm_profile_store().resolve_provider_connection(llm, cipher=cipher) under store_errors() immediately after decrypting the posted secrets. This is byte-for-byte the pattern already used by switch_llm (conversation_router.py:647-648) and activation via LLMProfileStore.load (profiles_router.py:486-487), so the pre-flight now runs on the connection's api_key/base_url exactly like the paths it claims to mirror.
  • Placement is correct: resolution runs after decryption and before the subscription branch, matching the issue's suggested fix and keeping the subscription credential path intact.
  • _resolve_provider_connection is a no-op when provider_connection_id is unset or no provider store is configured, so the ordinary inline-key and unlinked-draft paths are unchanged (the existing validate tests pass unchanged).
  • A dangling provider_connection_id raises ProviderConnectionNotFound, which store_errors() maps to 422 with a message naming the connection — the same answer activation and switch_llm give, satisfying acceptance criterion 2.

Tests

  • Both new tests in tests/agent_server/test_profiles_router.py use the real ProviderConnectionStore fixture (no mocking of the resolution path). The linked-draft test asserts the connection's api_key/base_url actually reach the LLM call, and the dangling-link test asserts 422 naming the connection and that no LLM call is made. I ran the suite: 111 passed.

Map / acceptance

  • The known-bug marker on F23.validate-linked-draft is removed and the prose updated to the expected behavior. control-agent-server map check reports ok: true (34 files, 935 ids, no problems).
  • The PR body documents authentic before/after evidence on the real F23.validate-linked-draft recipe (xfail on the base checkout, xpass on this head, pass after marker removal), which meets the repository's live-evidence expectation for a runtime-path bug fix.

CI

All check runs on head 217927e9 are green (pre-commit, integration-test, smoke-test, coverage-report, endpoint-audit, OpenAPI breakage check, docstrings, builds).

No correctness, security, compatibility, or acceptance-criterion defect found on the current head.

✅ APPROVED

@enyst
enyst merged commit 753ac51 into main Oct 22, 2026
60 of 61 checks passed
@enyst
enyst deleted the claude/umbrella-bug-fixes-tgz9ai-validate-linked-draft branch October 22, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: /api/profiles/{name}/validate ignores provider_connection_id: linked draft valid:false, expected true

3 participants