Skip to content

fix(billing): cast outbox payloads for JSONB operators - #6928

Merged
icecrasher321 merged 1 commit into
stagingfrom
codex/fix-pg18-outbox-jsonb
Aug 21, 2026
Merged

fix(billing): cast outbox payloads for JSONB operators#6928
icecrasher321 merged 1 commit into
stagingfrom
codex/fix-pg18-outbox-jsonb

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

  • explicitly cast JSON outbox payloads before JSONB-only follow-up correlation operators
  • cover both Enterprise provisioning rollups and shared outbox correlation
  • add regression assertions for the generated SQL expressions

Type of Change

  • Bug fix

Testing

  • bun run lint
  • bun run type-check
  • bun run check:audits
  • bun run check:api-validation
  • bun run apps/sim/scripts/check-block-registry.ts origin/staging
  • bunx vitest run lib/billing/enterprise-provisioning.test.ts lib/core/outbox/service.test.ts (78 tests)

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added and passing
  • 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 Aug 21, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 21, 2026 6:17am

Request Review

@cursor

cursor Bot commented Aug 21, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches SQL used to correlate billing follow-up jobs with parent operations; a wrong cast or operator would miscount or miss related outbox events. The change is small and covered by SQL-shape regression tests.

Overview
Fixes parent-operation correlation SQL that applied JSONB-only operators (->, ?|, @>) to JSON outbox payloads without a cast.

Enterprise follow-up rollups now cast payload::jsonb before reading sourceOperationIds (array unnest join and ?| filter). Shared outboxEventHasSourceOperationId does the same for containment checks.

Tests assert the generated SQL includes ::jsonb -> 'sourceOperationIds'.

Reviewed by Cursor Bugbot for commit 7ac3614. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes outbox follow-up correlation against the PostgreSQL json payload column by explicitly casting payloads before applying JSONB-only operators.

  • Casts Enterprise provisioning rollup expressions before JSONB type checks, array expansion, and ?| filtering.
  • Casts the shared outbox parent-operation predicate before JSONB containment.
  • Adds regression assertions covering the generated SQL expressions.

Confidence Score: 5/5

The PR appears safe to merge, with no actionable correctness or security issues identified.

The outbox payload column is non-null PostgreSQL JSON, and the explicit casts make the existing JSONB operators type-compatible while preserving matching behavior for the string operation identifiers written by current callers.

Important Files Changed

Filename Overview
apps/sim/lib/billing/enterprise-provisioning.ts Adds the required JSON-to-JSONB casts to Enterprise follow-up rollup expressions without changing their correlation semantics.
apps/sim/lib/billing/enterprise-provisioning.test.ts Adds focused assertions that the generated join and filter expressions contain the required JSONB casts and operators.
apps/sim/lib/core/outbox/service.ts Corrects the shared source-operation predicate so JSONB containment receives compatible operands.
apps/sim/lib/core/outbox/service.test.ts Adds a regression assertion for the JSONB cast and containment expression generated by the shared predicate.

Reviews (1): Last reviewed commit: "fix(billing): cast outbox payloads for J..." | Re-trigger Greptile

@icecrasher321
icecrasher321 merged commit fd5ea3e into staging Aug 21, 2026
30 checks passed
@icecrasher321
icecrasher321 deleted the codex/fix-pg18-outbox-jsonb branch August 21, 2026 06:22
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