Skip to content

[superlog] Log batch_union fallback as WARN instead of ERROR#513

Merged
izadoesdev merged 1 commit into
stagingfrom
codex/superlog-warn-batch-union-fallback
Jun 30, 2026
Merged

[superlog] Log batch_union fallback as WARN instead of ERROR#513
izadoesdev merged 1 commit into
stagingfrom
codex/superlog-warn-batch-union-fallback

Conversation

@izadoesdev

@izadoesdev izadoesdev commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary

  • add a request-aware captureWarning helper for recovered AI warnings
  • log recovered batch_union fallback failures at WARN instead of ERROR
  • preserve batch fallback metadata on the warning event
  • add focused coverage that recovered union fallback warns without error logging

Supersedes #502 with a clean branch from current staging.

Verification

  • cd packages/ai && bun test src/query/batch-executor.test.ts
  • cd packages/ai && bun run check-types
  • bun run lint
  • bun run check-types
  • bun run test

Summary by cubic

Logs recovered batch_union fallbacks as WARN instead of ERROR to reduce noise while keeping context. Adds a request-aware captureWarning and preserves fallback metadata on the warning event.

  • Bug Fixes
    • Use captureWarning to log union failures at WARN when single-query fallbacks succeed.
    • Preserve batch_union metadata on the warning: batch_union_fallback, batch_union_error, batch_size, batch_types.
    • Add tests to assert WARN (no ERROR) on recovered union fallback and correct results.

Written for commit 6dfcd52. Summary will update on new commits.

Review in cubic

@vercel
vercel Bot temporarily deployed to Preview – documentation June 30, 2026 16:12 Inactive
@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
databuddy-status Ready Ready Preview, Comment Jun 30, 2026 4:13pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
dashboard Skipped Skipped Jun 30, 2026 4:13pm
documentation Skipped Skipped Jun 30, 2026 4:13pm

@vercel
vercel Bot temporarily deployed to Preview – dashboard June 30, 2026 16:12 Inactive
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bcdd11dc-9677-48fb-875f-c0f53bd0c86c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/superlog-warn-batch-union-fallback

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.

@izadoesdev

Copy link
Copy Markdown
Member Author

Clean replacement for #502, rebased onto current staging after #512 merged.

What changed:

  • adds captureWarning for recovered AI warning paths
  • logs recovered batch_union fallback failures at WARN instead of ERROR
  • preserves fallback/error metadata on the warning payload
  • adds focused coverage proving recovered union fallback warns without error logging

Local verification passed:

  • cd packages/ai && bun test src/query/batch-executor.test.ts
  • cd packages/ai && bun run check-types
  • bun run lint
  • bun run check-types
  • bun run test

@unkey-deploy

unkey-deploy Bot commented Jun 30, 2026

Copy link
Copy Markdown

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

Name Status Preview Inspect Updated (UTC)
api (preview) Failed Visit Preview Inspect Jun 30, 2026 4:15pm

@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR downgrades the batch_union fallback from an error to a warning, since the executor recovers by running each query individually. It introduces a new captureWarning helper in tracing.ts and wires it into the catch block alongside focused test coverage.

  • captureWarning helper — mirrors captureError's structure (request-logger-aware), calling requestLog.warn(message, payload) when a logger is active and log.warn(...) otherwise; the fallback path additionally spreads error_stack unlike captureError.
  • batch-executor.ts catch block — replaces captureError with captureWarning, deduplicates the batchUnionError string, and adds batch_union_fallback/batch_union_error to both the warning payload and mergeWideEvent.
  • Test — new describe block verifies warn fires with correct metadata and error is not called after a union failure that recovers via single-query fallback.

Confidence Score: 4/5

The change is a focused, well-tested reclassification of a recovered error path from ERROR to WARN; the executor's fallback behavior itself is unchanged.

The new captureWarning helper contains a small asymmetry: its fallback log.warn spreads error_stack while the adjacent captureError fallback log.error does not. This means a recovered warning carries more stack context in the fallback logger than a genuine error, which could complicate triage. Everything else — the logger dispatch logic, deduplication of batchUnionError, and test coverage — is clean and correct.

packages/ai/src/lib/tracing.ts — the error_stack inclusion in captureWarning's fallback path deserves a second look for consistency with captureError.

Important Files Changed

Filename Overview
packages/ai/src/lib/tracing.ts Adds captureWarning helper mirroring captureError structure; minor inconsistency: fallback log.warn includes error_stack while sibling captureError's fallback log.error does not
packages/ai/src/query/batch-executor.ts Swaps captureErrorcaptureWarning for recovered batch_union fallback; deduplicates batchUnionError computation; adds fallback metadata to the warning payload — logic is correct
packages/ai/src/query/batch-executor.test.ts Adds focused test for union fallback warn path; correctly resets singleton provider in beforeEach; mock covers all called logger methods

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant BE as batch-executor
    participant TRC as tracing.ts
    participant RL as RequestLogger (evlog)
    participant LOG as log (evlog fallback)

    BE->>TRC: "captureWarning(error, {operation, batch_types, batch_size, batch_union_fallback, batch_union_error})"
    alt Request logger active
        TRC->>RL: requestLog.warn(err.message, payload)
        TRC-->>BE: return
        BE->>TRC: "mergeWideEvent({batch_union_fallback, batch_union_error})"
        TRC->>RL: "requestLog.set({batch_union_fallback, batch_union_error})"
    else No request logger
        TRC->>LOG: "log.warn({service, error_message, error_stack?, ...payload})"
        TRC-->>BE: return
        BE->>TRC: "mergeWideEvent({batch_union_fallback, batch_union_error})"
        TRC->>LOG: "log.info({service, batch_union_fallback, batch_union_error})"
    end
    BE->>BE: runSingle() per item (fallback)
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 BE as batch-executor
    participant TRC as tracing.ts
    participant RL as RequestLogger (evlog)
    participant LOG as log (evlog fallback)

    BE->>TRC: "captureWarning(error, {operation, batch_types, batch_size, batch_union_fallback, batch_union_error})"
    alt Request logger active
        TRC->>RL: requestLog.warn(err.message, payload)
        TRC-->>BE: return
        BE->>TRC: "mergeWideEvent({batch_union_fallback, batch_union_error})"
        TRC->>RL: "requestLog.set({batch_union_fallback, batch_union_error})"
    else No request logger
        TRC->>LOG: "log.warn({service, error_message, error_stack?, ...payload})"
        TRC-->>BE: return
        BE->>TRC: "mergeWideEvent({batch_union_fallback, batch_union_error})"
        TRC->>LOG: "log.info({service, batch_union_fallback, batch_union_error})"
    end
    BE->>BE: runSingle() per item (fallback)
Loading

Reviews (1): Last reviewed commit: "fix(ai): warn on recovered batch union f..." | Re-trigger Greptile

Comment on lines +31 to +36
log.warn({
service: "api",
error_message: err.message,
...(err.stack ? { error_stack: err.stack } : {}),
...(payload ?? {}),
});

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.

P2 captureWarning's fallback path includes error_stack in the structured log object, but the sibling captureError function's fallback log.error call does not. This means a recovered warning ends up with more stack context in the fallback logger than a genuine error, which inverts expectations and could make error triage harder when the request logger is absent.

Suggested change
log.warn({
service: "api",
error_message: err.message,
...(err.stack ? { error_stack: err.stack } : {}),
...(payload ?? {}),
});
log.warn({
service: "api",
error_message: err.message,
...(payload ?? {}),
});

@izadoesdev
izadoesdev merged commit 52c2c07 into staging Jun 30, 2026
19 checks passed
@izadoesdev
izadoesdev deleted the codex/superlog-warn-batch-union-fallback branch June 30, 2026 16:20
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