Skip to content

fix(httpapi): model optional session payloads as no content#29247

Merged
kitlangton merged 3 commits into
anomalyco:devfrom
kitlangton:kit/httpapi-optional-session-payloads
May 25, 2026
Merged

fix(httpapi): model optional session payloads as no content#29247
kitlangton merged 3 commits into
anomalyco:devfrom
kitlangton:kit/httpapi-optional-session-payloads

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

@kitlangton kitlangton commented May 25, 2026

Summary

  • Model bodyless session forks with HttpApiSchema.NoContent rather than a top-level Schema.optional payload.
  • Keep the existing raw request parser in place because it preserves legacy handling for whitespace-only bodies and malformed JSON.
  • Add regression coverage for bodyless forks without Content-Type, whitespace-only bodies, and malformed JSON returning 400.

Context

HttpApiSchema.NoContent is the intended HttpApi representation for an endpoint that accepts either a JSON payload or no request body. This follows the Effect maintainer guidance in Effect-TS/effect-smol#2187 (comment).

During review I verified that switching this route entirely to standard HttpApi decoding would change malformed JSON from 400 to 500, so this PR deliberately updates the declaration without removing the compatibility parser.

Verification

  • bun prettier --write test/server/httpapi-session.test.ts
  • bun oxlint packages/opencode/src/server/routes/instance/httpapi/groups/session.ts packages/opencode/test/server/httpapi-session.test.ts (passes with existing warnings in the test file)
  • bun typecheck from packages/opencode
  • bun run test -- test/server/httpapi-session.test.ts from packages/opencode
  • ./packages/sdk/js/script/build.ts (no generated SDK changes)

Note

  • Initial push used --no-verify after confirmation because the repository pre-push hook failed in unchanged packages/app/src/pages/session/message-timeline.tsx:584 (VirtualizerHandle has no measure property). CI typecheck subsequently passed for the original PR revision.

@kitlangton kitlangton merged commit a99ebd1 into anomalyco:dev May 25, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant