Skip to content

feat(client): add BashClient.batchGetEvents server-side batch endpoint#245

Merged
VascoSch92 merged 2 commits into
mainfrom
vasco/bash-batch-events
Jun 29, 2026
Merged

feat(client): add BashClient.batchGetEvents server-side batch endpoint#245
VascoSch92 merged 2 commits into
mainfrom
vasco/bash-batch-events

Conversation

@VascoSch92

Copy link
Copy Markdown
Member

Summary

Split from #231 (one feature per PR). Adds client coverage for the server-side bash batch endpoint that the audit reported as missing.

Endpoint Status before Change
GET /api/bash/bash_events/ (batch) missing new BashClient.batchGetEvents()

Details

  • This endpoint is declared GET-with-required-body, which fetch rejects (TypeError: Request with GET/HEAD method cannot have body). HttpClient now routes GET-with-body requests through Node's http/https module (requestWithBodyOnGet + parseNodeResponse), mirroring the fetch path's URL/header/error/parse behavior; every other request is untouched.
  • Unlike getEvents (which fans out one request per id), batchGetEvents calls the server-side batch endpoint and returns one entry per requested id, with null in the slots of any missing event — preserving input order.

Note: the GET-with-body HttpClient infrastructure here is shared with the conversation batch-events PR (split from the same audit). The two are intentionally identical so they merge cleanly.

Testing

  • Unit (src/__tests__/api-clients.test.ts): mocks node:http (the GET-body transport) and asserts the request method/URL/body and the null-for-missing mapping.
  • Integration (bash.integration.test.ts): real event ids round-trip through the batch endpoint and a bogus id comes back as null in place.
  • npm run build, lint (0 errors), and format:check pass; full unit suite green (270).

Adds coverage for the server-side bash batch endpoint:

- GET /api/bash/bash_events/ -> BashClient.batchGetEvents()

This endpoint is declared GET-with-required-body, which `fetch` rejects
("Request with GET/HEAD method cannot have body"). HttpClient now routes
GET-with-body requests through Node's http(s) module (requestWithBodyOnGet
+ parseNodeResponse), mirroring the fetch path's URL/header/error/parse
behavior; every other request is untouched. Unlike getEvents (one request
per id), batchGetEvents returns one entry per requested id with null in
the slots of missing events, preserving input order.

Includes a unit test (mocked node:http, asserting method/URL/body and
the null-for-missing mapping) and an integration assertion in
bash.integration.test.ts (real ids round-trip, a bogus id comes back as
null in place).
@github-actions github-actions Bot added the type: feat A new feature label Jun 29, 2026
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Endpoint audit

❌ 7 off-contract call(s) — not on the agent-server · classifiers: cloud

Category Count
❌ Off-contract (not on agent-server) 7
  ⛔ no known backend 6
  ↗️ served by cloud 1
➕ Missing API (agent-server has, client lacks) 7
agent-server endpoints 112
client endpoints 110

❌ Not on agent-server (gated, 7)

⛔ (no known backend) — served by no backend we can see (6)

  • DELETE /api/meta-profiles/{}
  • GET /api/meta-profiles
  • GET /api/meta-profiles/{}
  • POST /api/cloud-proxy
  • POST /api/meta-profiles/{}
  • POST /api/meta-profiles/{}/activate

↗️ served by cloud (1)

  • GET /api/shared-events/search

➕ Missing API — agent-server exposes it, client does not implement (7)

  • GET /
  • GET /api/conversations
  • GET /api/conversations/{}/events
  • GET /api/conversations/{}/workspace
  • GET /api/conversations/{}/workspace/{}
  • GET /api/init
  • POST /api/init

all-hands-bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review complete.

This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Acceptable — The approach is pragmatic and correct: fetch genuinely rejects GET bodies, routing those calls through Node's http/https module is the right workaround, and the early-return guard in request() is tight enough that no existing call is affected. Both a unit test (mocked transport, asserts method/URL/body/null-mapping) and an integration test (real round-trip with a bogus-id slot check) are present.

One structural issue is worth cleaning up — particularly because the PR description notes an identical pattern is coming in the conversations batch-event PR: the URL-construction and params-handling block is copy-pasted verbatim between request() and requestWithBodyOnGet(). See inline comment.

[IMPROVEMENT OPPORTUNITIES]

  • [src/client/http-client.ts] Duplication: URL-building block copy-pasted from request() — extract a buildUrl() helper (see inline).
  • [src/tests/api-clients.test.ts, Line 2150] Noise comment: Repeats the module-mock preamble already present at the top of the file.

[RISK ASSESSMENT]

  • [Overall PR] ⚠️ Risk Assessment: 🟡 MEDIUM
    HttpClient.request() is a widely-imported shared utility and this PR adds an early-return branch to it. The guard condition (method === 'GET' && data !== undefined && data !== null) is narrow and correct — no existing call passes a non-null body on a GET, so the fetch path is untouched — but any shared core utility that gains conditional routing deserves attention. Mitigated by the tight guard, full unit coverage, and an integration test.

VERDICT:
Worth merging: Core logic is correct and well-tested. The URL-duplication is worth fixing before the conversations batch-event companion PR lands (to avoid a third copy).

KEY INSIGHT:
The URL-building block shared between request() and requestWithBodyOnGet() will be copied a third time when the conversations batch-endpoint PR merges — extract buildUrl() now rather than after three copies exist.

This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation


Improve this review? If any feedback above seems incorrect or irrelevant to this repository, you can teach the reviewer to do better:

  1. Add a .agents/skills/custom-codereview-guide.md file to your branch (or edit it if one already exists) with the /codereview trigger and the context the reviewer is missing. See the customization docs for the required frontmatter format.
  2. Re-request a review - the reviewer reads guidelines from the PR branch, so your changes take effect immediately.
  3. When your PR is merged, the guideline file goes through normal code review by repository maintainers.

Resolve with AI? Install the iterate skill in your agent and run /iterate to automatically drive this PR through CI, review, and QA until it's merge-ready.

Was this review helpful? React with 👍 or 👎 to give feedback.

Comment thread src/client/http-client.ts Outdated
Comment thread src/__tests__/api-clients.test.ts Outdated
@VascoSch92

Copy link
Copy Markdown
Member Author

@OpenHands adress the suggestions

@openhands-ai

openhands-ai Bot commented Jun 29, 2026

Copy link
Copy Markdown

I'm on it! VascoSch92 can track my progress at all-hands.dev

Co-authored-by: openhands <openhands@all-hands.dev>
@openhands-ai

openhands-ai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Done.

  • Addressed both PR suggestions:
    • Extracted duplicated URL construction into HttpClient.buildUrl().
    • Removed the redundant test-body comment.
  • Committed and pushed to vasco/bash-batch-events:
    • 887bbab9c16c303df819d0096a539d5960215551
  • Replied to both inline review threads and resolved them.
  • Validation passed:
    • npm test -- --runTestsByPath src/__tests__/api-clients.test.ts --runInBand
    • npm run lint — 0 errors, existing warnings only
    • npm run build
    • npm run format:check

PR CI is currently pending on the latest commit.

@VascoSch92 VascoSch92 merged commit 063656e into main Jun 29, 2026
11 checks passed
@openhands-release-bot openhands-release-bot Bot added the released: v1.32.0 Shipped in v1.32.0 label Jul 7, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in v1.32.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released: v1.32.0 Shipped in v1.32.0 type: feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants