Skip to content

[superlog] Set correct HTTP status on custom ORPC error codes to suppress false-positive ERRORs#509

Merged
izadoesdev merged 1 commit into
stagingfrom
superlog/fix-custom-orpc-error-status-codes
Jun 30, 2026
Merged

[superlog] Set correct HTTP status on custom ORPC error codes to suppress false-positive ERRORs#509
izadoesdev merged 1 commit into
stagingfrom
superlog/fix-custom-orpc-error-status-codes

Conversation

@superlog-app

@superlog-app superlog-app Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Users hitting plan limits, feature gates, or rate limits on the API triggered false-positive ERROR-level Superlog incidents. The root cause is that three Databuddy-custom ORPC error codes — PLAN_LIMIT_EXCEEDED, FEATURE_UNAVAILABLE, and RATE_LIMITED — are not in ORPC's built-in status table, so ORPCError defaulted their HTTP status to 500 instead of 402 / 403 / 429.

The existing downgrade in apps/api/src/lib/evlog-api.ts (normalizeWideEventForAxiom) already correctly demotes any error with a 4xx status from ERROR to WARN before it reaches Superlog or Axiom. But because the status was 500, the guard (status >= 400 && status < 500) never fired, and every plan-limit hit became an incident.

The fix passes the correct status in the ORPCError constructor for each of the three affected helpers in packages/rpc/src/errors.ts, matching what baseErrors already declares for these codes. No logic change — only the status propagation that was missing.

Incident on Superlog


Was this PR helpful? Leave feedback — goes straight to the Superlog team.


Summary by cubic

Set correct HTTP status codes for custom ORPC errors to stop false-positive ERROR incidents in Superlog. FEATURE_UNAVAILABLE → 403, RATE_LIMITED → 429, and PLAN_LIMIT_EXCEEDED → 402 so 4xx errors are demoted to WARN as intended.

  • Bug Fixes
    • Pass explicit status to ORPCError in packages/rpc/src/errors.ts.
    • Plan limits, feature gates, and rate limits now log as WARN via the existing 4xx guard.
    • No logic changes; messages and data remain the same.

Written for commit 3aca67a. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
dashboard Ready Ready Preview, Comment Jun 29, 2026 11:03pm
databuddy-status Ready Ready Preview, Comment Jun 29, 2026 11:03pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
documentation Skipped Skipped Jun 29, 2026 11:03pm

@unkey-deploy

unkey-deploy Bot commented Jun 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Unkey Deploy

Name Status Preview Inspect Updated (UTC)
api (preview) Ready Visit Preview Inspect Jun 29, 2026 11:02pm

@greptile-apps

greptile-apps Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes false-positive ERROR-level log incidents by explicitly setting the correct HTTP status code on three custom ORPCError constructors (FEATURE_UNAVAILABLE → 403, RATE_LIMITED → 429, PLAN_LIMIT_EXCEEDED → 402). Because these codes are not in ORPC's built-in status table, they previously defaulted to 500, bypassing the existing 4xx downgrade guard in evlog-api.ts.

  • Adds status: 403/429/402 to the featureUnavailable, rateLimited, and planLimitExceeded helpers in packages/rpc/src/errors.ts, matching the values already declared in baseErrors.
  • No logic change; only the missing status propagation to ORPCError is restored.

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to three error constructors, the new status values match the already-agreed baseErrors declarations, and the downstream 4xx guard in evlog-api.ts is unmodified.

Three one-line additions each aligning an ORPCError constructor with the status already declared in baseErrors. No branching logic, no schema changes, no client-visible contract changes beyond correcting a previously wrong HTTP status on non-standard ORPC codes.

No files require special attention.

Important Files Changed

Filename Overview
packages/rpc/src/errors.ts Adds explicit status overrides to three custom ORPCError constructors; statuses match baseErrors declarations and are correct HTTP semantics.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Client
    participant API as API Handler
    participant RE as rpcError helper
    participant ORPC as ORPCError
    participant Drain as apiLoggerDrain
    participant SL as Superlog

    Client->>API: Request (hits plan/rate/feature limit)
    API->>RE: rpcError.planLimitExceeded() / rateLimited() / featureUnavailable()
    RE->>ORPC: new ORPCError with status 402/429/403
    note over ORPC: Before fix: status defaulted to 500
    ORPC-->>API: ORPCError with correct status
    API->>Drain: "log event (level=error, error.status=402/429/403)"
    Drain->>Drain: normalizeWideEventForAxiom() guard fires
    note over Drain: status >= 400 and status < 500 → level=warn
    Drain->>SL: "event (level=warn) — no incident triggered"
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Client
    participant API as API Handler
    participant RE as rpcError helper
    participant ORPC as ORPCError
    participant Drain as apiLoggerDrain
    participant SL as Superlog

    Client->>API: Request (hits plan/rate/feature limit)
    API->>RE: rpcError.planLimitExceeded() / rateLimited() / featureUnavailable()
    RE->>ORPC: new ORPCError with status 402/429/403
    note over ORPC: Before fix: status defaulted to 500
    ORPC-->>API: ORPCError with correct status
    API->>Drain: "log event (level=error, error.status=402/429/403)"
    Drain->>Drain: normalizeWideEventForAxiom() guard fires
    note over Drain: status >= 400 and status < 500 → level=warn
    Drain->>SL: "event (level=warn) — no incident triggered"
Loading

Reviews (1): Last reviewed commit: "[superlog] Set correct HTTP status on cu..." | Re-trigger Greptile

@izadoesdev izadoesdev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed against staging. No blocking findings. This is a small, targeted status propagation fix: the three custom ORPC helpers now match the statuses already declared in baseErrors, which keeps expected 4xx outcomes from being logged as false-positive ERROR incidents. CI is green.

@izadoesdev
izadoesdev merged commit 3982184 into staging Jun 30, 2026
17 checks passed
@izadoesdev
izadoesdev deleted the superlog/fix-custom-orpc-error-status-codes branch June 30, 2026 14:42
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