Skip to content

fix(agent-server): refuse more than 99 batch-get ids with a 422 - #5795

Merged
enyst merged 1 commit into
mainfrom
claude/umbrella-bug-fixes-tgz9ai-batch-get-limit
Oct 17, 2026
Merged

enyst merged 1 commit into
mainfrom
claude/umbrella-bug-fixes-tgz9ai-batch-get-limit

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:

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

Requested by Engel · project thread

Why

GET /api/conversations (the batch get) accepts at most 99 ids, but the limit was a bare assert len(ids) < 100. With 100 or more ids the failed assertion reached the catch-all handler and came back as 500 {"detail": "Internal Server Error", "exception": ""}. The caller had no way to tell it had sent too many ids, the limit was missing from OpenAPI, and the check disappeared under python -O.

Summary

  • Declare the limit as ids: Annotated[list[UUID], Query(max_length=99)] and drop the assert. 100+ ids now get a 422 ("List should have at most 99 items"), the service is not called, and OpenAPI shows maxItems: 99, following the declared le=100 on search limit ([Bug]: GET /api/conversations/search returns 500 for limit > 100 (no graceful clamp) #5114).
  • The router test now asserts the 422 (it used to assert the AssertionError), the 99-id 200, and the OpenAPI bound.
  • Remove the # bug marker from the F04.batch-get-limit map bullet. The recipe now expects a 422 whose body says at most 99 items.

As the issue triage scoped it, the 99-id limit stays the same and the TypeScript client gets no chunking. A TS batch of 100 ids now gets the 422 instead of a 500.

REST API contract changes

Compared with base OpenAPI 6a298a48fcdb for public /api/** paths.

--- base public OpenAPI
+++ head public OpenAPI
@@ -195 +195 @@
-parameter GET /api/conversations query:ids required=true schema=type="array" items=type="string" format="uuid"
+parameter GET /api/conversations query:ids required=true schema=type="array" items=type="string" format="uuid" maxItems=99

Issue Number

Fixes #5790

How to Test

  • uv run pytest -q tests/agent_server/test_conversation_router.py tests/agent_server/test_openapi_contract.py: 108 passed. With the router change reverted, the two batch tests (too_many_ids, openapi_declares_id_limit) fail.
  • Map proof, with AGENT_SERVER_VERIFY_HOME isolated:
    • baseline (origin/main 6a298a4): control-agent-server map run --file F04 --only F04.batch-get-limit --fresh --repeat 2 --checkout <main checkout> reports xfail in both attempts.
    • this branch, before the marker was removed: the same run reports xpass in both attempts.
    • after removing the marker: control-agent-server map check is ok, and map run --file F04 --only F04.batch-get-limit --fresh reports pass.
  • uv run pre-commit run --files <changed files> passes.

Video/Screenshots

n/a

Type

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

Notes

Tracked in the umbrella #5653.

🤖 Generated with Claude Code

https://claude.ai/code/session_014MKndVj7XWvRQmvW9w2bDg


Generated by Claude Code


🐳 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:f2ac77c-python

Run

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

All tags pushed for this build

ghcr.io/openhands/agent-server:f2ac77c-golang-amd64
ghcr.io/openhands/agent-server:f2ac77c0f4d438e6ec189c3f640886ef7191e6ea-golang-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-batch-get-limit-golang-amd64
ghcr.io/openhands/agent-server:f2ac77c-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:f2ac77c-golang-arm64
ghcr.io/openhands/agent-server:f2ac77c0f4d438e6ec189c3f640886ef7191e6ea-golang-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-batch-get-limit-golang-arm64
ghcr.io/openhands/agent-server:f2ac77c-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:f2ac77c-java-amd64
ghcr.io/openhands/agent-server:f2ac77c0f4d438e6ec189c3f640886ef7191e6ea-java-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-batch-get-limit-java-amd64
ghcr.io/openhands/agent-server:f2ac77c-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:f2ac77c-java-arm64
ghcr.io/openhands/agent-server:f2ac77c0f4d438e6ec189c3f640886ef7191e6ea-java-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-batch-get-limit-java-arm64
ghcr.io/openhands/agent-server:f2ac77c-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:f2ac77c-python-amd64
ghcr.io/openhands/agent-server:f2ac77c0f4d438e6ec189c3f640886ef7191e6ea-python-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-batch-get-limit-python-amd64
ghcr.io/openhands/agent-server:f2ac77c-python-node-runtime-amd64
ghcr.io/openhands/agent-server:f2ac77c-python-arm64
ghcr.io/openhands/agent-server:f2ac77c0f4d438e6ec189c3f640886ef7191e6ea-python-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-batch-get-limit-python-arm64
ghcr.io/openhands/agent-server:f2ac77c-python-node-runtime-arm64
ghcr.io/openhands/agent-server:f2ac77c-python-minimal-amd64
ghcr.io/openhands/agent-server:f2ac77c0f4d438e6ec189c3f640886ef7191e6ea-python-minimal-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-batch-get-limit-python-minimal-amd64
ghcr.io/openhands/agent-server:f2ac77c-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:f2ac77c-python-minimal-arm64
ghcr.io/openhands/agent-server:f2ac77c0f4d438e6ec189c3f640886ef7191e6ea-python-minimal-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-batch-get-limit-python-minimal-arm64
ghcr.io/openhands/agent-server:f2ac77c-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:f2ac77c-python-slim-amd64
ghcr.io/openhands/agent-server:f2ac77c0f4d438e6ec189c3f640886ef7191e6ea-python-slim-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-batch-get-limit-python-slim-amd64
ghcr.io/openhands/agent-server:f2ac77c-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:f2ac77c-python-slim-arm64
ghcr.io/openhands/agent-server:f2ac77c0f4d438e6ec189c3f640886ef7191e6ea-python-slim-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-batch-get-limit-python-slim-arm64
ghcr.io/openhands/agent-server:f2ac77c-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:f2ac77c-golang
ghcr.io/openhands/agent-server:f2ac77c0f4d438e6ec189c3f640886ef7191e6ea-golang
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-batch-get-limit-golang
ghcr.io/openhands/agent-server:f2ac77c-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:f2ac77c-java
ghcr.io/openhands/agent-server:f2ac77c0f4d438e6ec189c3f640886ef7191e6ea-java
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-batch-get-limit-java
ghcr.io/openhands/agent-server:f2ac77c-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:f2ac77c-python-minimal
ghcr.io/openhands/agent-server:f2ac77c0f4d438e6ec189c3f640886ef7191e6ea-python-minimal
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-batch-get-limit-python-minimal
ghcr.io/openhands/agent-server:f2ac77c-python-node-runtime-minimal
ghcr.io/openhands/agent-server:f2ac77c-python-slim
ghcr.io/openhands/agent-server:f2ac77c0f4d438e6ec189c3f640886ef7191e6ea-python-slim
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-batch-get-limit-python-slim
ghcr.io/openhands/agent-server:f2ac77c-python-node-runtime-slim
ghcr.io/openhands/agent-server:f2ac77c-python
ghcr.io/openhands/agent-server:f2ac77c0f4d438e6ec189c3f640886ef7191e6ea-python
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-batch-get-limit-python
ghcr.io/openhands/agent-server:f2ac77c-python-node-runtime

About Multi-Architecture Support

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

GET /api/conversations enforced its 99-id limit with a bare assert, so
100 or more ids became a 500 with an empty exception. Declare the limit
as Query(max_length=99) instead: the request is a 422 naming the limit,
the service is not called, and OpenAPI shows maxItems: 99. Drop the
known-bug marker from the F04.batch-get-limit map bullet.

Fixes #5790

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014MKndVj7XWvRQmvW9w2bDg
@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
   conversation_router.py2941994%107–108, 112–113, 245, 387, 471, 518, 578, 759–762, 774–777, 817, 855
TOTAL497381987760% 

@enyst
enyst marked this pull request as ready for review October 13, 2026 23:32
@enyst
enyst requested a review from all-hands-bot October 13, 2026 23:34

@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 #5795 — refuse more than 99 batch-get ids with a 422

Scope

Agent-server REST API change (the canonical API owned by this repository). It replaces an assert-based batch-size guard with a declared FastAPI/Pydantic query constraint, matching the authoritative pattern already used for the search limit (Query(gt=0, le=100), #5114). In scope; no cross-repository ownership issue.

What I verified on the current head (f2ac77c0)

  • Runtime behavior. ids: Annotated[list[UUID], Query(max_length=99)] turns 100 ids into a FastAPI 422 ("List should have at most 99 items") before the handler body runs, so conversation_service.batch_get_conversations is not called. The new mock_conversation_service.batch_get_conversations.assert_not_called() in test_batch_get_conversations_too_many_ids confirms nothing reaches the service.
  • 99 ids still work. The same test asserts 200 with [None] * 99, and the router tests I ran pass (109 passed for tests/agent_server/test_conversation_router.py tests/agent_server/test_openapi_contract.py).
  • OpenAPI declaration. test_batch_get_conversations_openapi_declares_id_limit asserts maxItems == 99 on the ids parameter, so the bound is in the published schema, not only enforced. This matches the PR's OpenAPI contract diff.
  • Assert removal. The message-less AssertionError that produced 500 {"detail": "Internal Server Error", "exception": ""} is gone, and the check no longer disappears under python -O.
  • CI. All check runs on f2ac77c0 are success/skipped; no failing or pending required check.
  • Issue #5790 is open with bug/priority:low/ready-for-dev; every acceptance criterion it lists (422 naming the limit, service not invoked, 99-id 200, declared schema bound, updated router test, # bug marker removed from F04.batch-get-limit) is addressed by this head.

Non-blocking observations (no action required)

  • The generated TypeScript schema (clients/typescript/src/generated/agent-server-schema.ts) is not regenerated here, but that file is produced by the generate:agent-server-api step in the version-bump/release workflows, and maxItems is not runtime-enforced by the TS client anyway. A TS batch of 100 ids now surfaces the 422 instead of a 500, which is the intended, in-scope behavior; client-side chunking is an explicit non-goal.
  • 0-id requests remain a 422 via the unchanged required Query() semantics — same as base.

No material correctness, security, compatibility, or acceptance-criterion defect found.

✅ APPROVED

@enyst
enyst merged commit 9d07c6d into main Oct 17, 2026
56 checks passed
@enyst
enyst deleted the claude/umbrella-bug-fixes-tgz9ai-batch-get-limit branch October 17, 2026 03:45
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]: GET /api/conversations with 100 or more ids returns 500 with an empty exception instead of a 4xx naming the limit

3 participants