Skip to content

fix(opencode): return documented 404 on project update for missing project#1090

Merged
Astro-Han merged 1 commit into
devfrom
claude/i936-project-notfound
Jun 3, 2026
Merged

fix(opencode): return documented 404 on project update for missing project#1090
Astro-Han merged 1 commit into
devfrom
claude/i936-project-notfound

Conversation

@Astro-Han
Copy link
Copy Markdown
Owner

Summary

PATCH /:projectID declares errors(400, 404) in its OpenAPI responses, but Project.update threw a bare Error when the project row did not exist. A bare Error is not a NamedError, so ErrorMiddleware fell through to its default branch and returned an undocumented 500 instead of the declared 404.

Same contract-alignment pattern as #1067 / #1082: align a route to its already-declared 4xx instead of leaking a 500. No new contract surface — 404 was already declared.

Touched files

  • src/project/project.ts — throw the typed NotFoundError (mapped to 404 by ErrorMiddleware) instead of a bare Error on the missing-row path. Same Project not found: <id> text now in data.message; body matches the declared NotFoundError.Schema.
  • test/project/project.test.ts — the existing not-found test asserted .toThrow("Project not found: ..."), but NamedError sets Error.message to its name, so the business message moved to data.message. Updated to assert { name, data.message }.
  • test/server/project-routes.test.ts — new HTTP regression: PATCH on a non-existent project returns 404 with the NotFoundError body.

Verification

  • bun run typecheck (tsgo) — green
  • targeted: test/project/project.test.ts, test/server/project-routes.test.ts, test/server/route-inventory-harness.test.ts — 39 pass / 0 fail

Risk

Low. Pure error-contract alignment: success path, response body shape, status of already-correct surfaces, and operationId all unchanged. The only behavior change is the missing-project failure moving from an undocumented 500 to the already-declared 404. Project.update now rejects with NotFoundError rather than a bare Error; the one in-repo consumer asserting the old message was updated, and the front-end consumer (layout.tsx via SDK) only observes the HTTP status, where 404 was already part of the declared contract.

ref #936

…oject

PATCH /:projectID declares errors(400, 404) in its OpenAPI responses, but
Project.update threw a bare Error when the project row did not exist. A bare
Error is not a NamedError, so ErrorMiddleware fell through to its default branch
and returned an undocumented 500 instead of the declared 404.

- src/project/project.ts: throw the typed NotFoundError (already mapped to 404 by
  ErrorMiddleware) instead of a bare Error on the missing-row path. NotFoundError
  carries the same "Project not found: <id>" text in its data.message and is
  exactly the 404 body shape (NotFoundError.Schema) the route already declares.
- test/project/project.test.ts: the existing not-found test asserted
  .toThrow("Project not found: ..."), but NamedError sets Error.message to its
  name ("NotFoundError"), so the business message now lives in data.message.
  Updated the assertion to match {name, data.message}.
- test/server/project-routes.test.ts: new HTTP regression asserting PATCH on a
  non-existent project returns 404 with the NotFoundError body.

No change to the success path, response body shape, status code of any
already-correct surface, or operationId. Mirrors #1067 / #1082 (aligning a route
to its already-declared 4xx contract).

ref #936
@Astro-Han Astro-Han added bug Something isn't working P2 Medium priority harness Model harness, prompts, tool descriptions, and session mechanics labels Jun 3, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Warning

Review limit reached

@Astro-Han, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 14 minutes and 15 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 08efb3e8-f056-473a-982b-698710b8c784

📥 Commits

Reviewing files that changed from the base of the PR and between 349fea1 and c293acd.

📒 Files selected for processing (3)
  • packages/opencode/src/project/project.ts
  • packages/opencode/test/project/project.test.ts
  • packages/opencode/test/server/project-routes.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/i936-project-notfound

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Suggested priority: P2 (includes non-doc, non-test paths outside the low-risk bucket).

P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request replaces a generic Error with a specific NotFoundError when a project is not found during an update. It also updates the corresponding unit tests and adds a new integration test file to verify that the PATCH route correctly returns a 404 status code and a NotFoundError response when a project does not exist. I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@Astro-Han Astro-Han merged commit ab54578 into dev Jun 3, 2026
34 of 36 checks passed
@Astro-Han Astro-Han deleted the claude/i936-project-notfound branch June 3, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working harness Model harness, prompts, tool descriptions, and session mechanics P2 Medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant