Skip to content

fix(kap-server): use HTTP error statuses for session export - #1670

Open
wbxl2000 wants to merge 2 commits into
mainfrom
codex/fix-session-export-error-status
Open

fix(kap-server): use HTTP error statuses for session export#1670
wbxl2000 wants to merge 2 commits into
mainfrom
codex/fix-session-export-error-status

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Related Issue

Follow-up to #1646, which added the Web session export endpoint and has since merged. This follow-up closes the serializer/schema gap found during review.

Problem

The export route declared a binary-only 200 response while validation and export failures also returned JSON envelopes with HTTP 200. Fastify could therefore apply the binary response contract to an error object, leaving the Web client with an opaque or malformed failure.

What changed

  • Return validation failures as HTTP 400, missing sessions as 404, archive-size failures as 413, and unexpected export failures as 500.
  • Keep the successful response as a streamed application/zip and declare the JSON error responses separately in the route/OpenAPI contract.
  • Preserve the historical 200/envelope behavior for other routes through an opt-in validation status on defineRoute.
  • Add HTTP-level regression coverage and update the Web client error mock.

Verification

  • pnpm exec vitest run test/sessions.test.ts test/openapi.test.ts --maxWorkers=1 in packages/kap-server (57 tests)
  • pnpm exec vitest run test/apiSurface.snapshot.test.ts --maxWorkers=1 in packages/kap-server
  • pnpm exec vitest run test/daemon-client.test.ts --maxWorkers=1 in apps/kimi-web (8 tests)
  • pnpm --filter @moonshot-ai/kap-server run typecheck
  • pnpm --filter @moonshot-ai/kimi-web run typecheck
  • git diff --check

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dc03712

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@pkg-pr-new

pkg-pr-new Bot commented Jul 14, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@dc03712
npx https://pkg.pr.new/@moonshot-ai/kimi-code@dc03712

commit: dc03712

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: dc03712388

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

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.

1 participant