Skip to content

feat(log): Add wrapper function for standardized logging#4061

Open
TheodoreSpeaks wants to merge 9 commits intostagingfrom
log/add-centralized-error-reporting
Open

feat(log): Add wrapper function for standardized logging#4061
TheodoreSpeaks wants to merge 9 commits intostagingfrom
log/add-centralized-error-reporting

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

@TheodoreSpeaks TheodoreSpeaks commented Apr 8, 2026

Summary

We have no centralized entry for our routes, making it hard to trace failing requests. Added request metadata for generating request id and returning a standardized output showing status code, path, and route.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • Tested locally, validated endpoints are being called.

Checklist

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

Screenshots/Videos

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 21, 2026 4:51am

Request Review

…d-error-reporting

# Conflicts:
#	apps/sim/app/api/organizations/[id]/invitations/[invitationId]/route.ts
#	apps/sim/app/api/workspaces/invitations/[invitationId]/route.ts
@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator Author

@BugBot review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 21, 2026

PR Summary

Medium Risk
Touches a large number of API routes (including auth/billing) by changing their export shape and wrapping execution, which could affect edge-case response handling and error propagation. Core behavior is mostly additive (request-id header, centralized logging, catch-all 500), but breadth of change raises regression risk.

Overview
Introduces a centralized withRouteHandler wrapper that generates a per-request ID, runs handlers inside request context, auto-logs 4xx/5xx (and success) responses with timing, attaches x-request-id, and converts unhandled exceptions into a standardized 500 response.

Applies this wrapper across many existing API endpoints (A2A, academy, admin proxy, audit logs, auth/OAuth/SSO, billing, chat, copilot), replacing bare export async function GET/POST/... with export const METHOD = withRouteHandler(...) without changing the underlying route logic.

Updates repo guidelines (.claude/rules/global.md, CLAUDE.md) to require withRouteHandler for all API route handlers and to note that loggers automatically include the request ID when wrapped.

Reviewed by Cursor Bugbot for commit 08213aa. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 08213aa. Configure here.

@TheodoreSpeaks TheodoreSpeaks marked this pull request as ready for review April 21, 2026 04:56
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