Skip to content

fix(idempotency): use compatible PostgreSQL JSON operations - #6510

Merged
TheodoreSpeaks merged 1 commit into
stagingfrom
feat/debug-stripe
Aug 11, 2026
Merged

fix(idempotency): use compatible PostgreSQL JSON operations#6510
TheodoreSpeaks merged 1 commit into
stagingfrom
feat/debug-stripe

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • use PostgreSQL json_typeof for the JSON-backed idempotency lease expiry check
  • cast both retry-fence operands to jsonb and add regression coverage for both mismatches

Type of Change

  • Bug fix

Testing

  • bun run lint
  • bun run apps/sim/scripts/check-block-registry.ts origin/staging
  • bun run check:audits
  • bun run test lib/core/idempotency/service.test.ts (from apps/sim)

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)

@vercel

vercel Bot commented Aug 11, 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 11, 2026 12:08am

Request Review

@cursor

cursor Bot commented Aug 11, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches correctness-critical idempotency claim/reclaim and retry-delete paths in Postgres; wrong SQL could leave keys stuck in-progress or delete the wrong row, but the change aligns types with the schema and adds regression tests.

Overview
Fixes database idempotency SQL so it matches the json column type on idempotency_key.result and compares retry fences correctly.

Lease expiry on claim: The in-progress reclaim check now uses json_typeof on the -> path instead of jsonb_typeof, which was invalid for a json column and could break reclaiming stale in-progress leases.

Retry failure delete: When deleting a failed row for retry, the WHERE clause now compares result::jsonb to the observed value ::jsonb, so both operands use the same type instead of comparing raw json to jsonb.

Tests assert the conflict setWhere uses json_typeof and that the delete condition includes two ::jsonb casts.

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

@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR fixes PostgreSQL type compatibility in database-backed idempotency operations.

  • Uses json_typeof for lease-expiry metadata stored in a json column.
  • Casts both retry-fence operands to jsonb to enable semantic equality.
  • Adds regression assertions for both SQL-expression mismatches.

Confidence Score: 5/5

The PR appears safe to merge with no actionable defects identified.

The changed SQL operations match the declared PostgreSQL json column type, and symmetric jsonb casts provide valid semantic equality for the database retry fence.

Important Files Changed

Filename Overview
apps/sim/lib/core/idempotency/service.ts Aligns lease-expiry inspection with the column's PostgreSQL json type and makes retry-fence equality valid by casting both operands to jsonb.
apps/sim/lib/core/idempotency/service.test.ts Adds focused regression assertions covering the corrected JSON type function and symmetric retry-fence casts.

Reviews (1): Last reviewed commit: "fix(idempotency): use compatible Postgre..." | Re-trigger Greptile

@TheodoreSpeaks
TheodoreSpeaks merged commit e0292fc into staging Aug 11, 2026
30 checks passed
@TheodoreSpeaks
TheodoreSpeaks deleted the feat/debug-stripe branch August 11, 2026 00:12
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