Skip to content

improvement(api): log the v2 error code, field, and refusal reason on the request's closing line - #10033

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/api-log-error-code-kb-list
Nov 14, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/api-log-error-code-kb-list

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • A v2 4xx logs only Client error response with its status, so a 400 from bad input can't be told apart from one the API refuses by design without reproducing the call
  • v2Error records the response's error.code, plus its details.code when the refusal names one, against the response object it builds. v2ValidationError adds the slice and its top-level field (body.mapping) and the Zod issue kind (invalid_type)
  • withRouteHandler reads that summary off the response it actually returns and adds errorCode / errorField / errorReason to its closing line. A response built only to extract a message is never logged
  • Never logged: the message, which can quote user input, and path segments below the top-level field, which can be record keys the caller wrote (e.g. CSV headers)

Type of Change

  • Improvement

Testing

  • Ran the real v2ValidationError / v2Error helpers: a record-key failure logs body.mapping while the response still names the full path; details.code comes through as the reason; an untagged response reads back nothing
  • app/api/v2/lib and with-route-handler tests (33) pass; biome, check:comment-hygiene, check:test-patterns clean; CI runs the rest

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Ignored Ignored Preview Nov 14, 2026 2:33am UTC

Request Review

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/app/api/v2/lib/response.ts Resolved
@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Adds response-specific error details to the route handler’s closing error log.

  • V2 request logs show why API errors were returned.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[v2 error helper] --> B[Response]
  A --> C[WeakMap summary]
  B --> D[Route returns response]
  D --> E[Closing error log]
  C -->|Look up returned response| E
Loading

Reviews (2) · Last reviewed commit: "improvement(api): tag the returned respo..." · Reviewed by Greptile

Comment thread apps/sim/app/api/v2/lib/response.ts Resolved
Comment thread apps/sim/app/api/v2/lib/response.ts Resolved
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 1562d56 into staging Nov 14, 2026
80 of 81 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/api-log-error-code-kb-list branch November 14, 2026 02:47
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