Skip to content

fix: sync org names to Stripe#1910

Merged
riderx merged 24 commits into
mainfrom
codex/stripe-org-name-sync
Apr 15, 2026
Merged

fix: sync org names to Stripe#1910
riderx merged 24 commits into
mainfrom
codex/stripe-org-name-sync

Conversation

@riderx
Copy link
Copy Markdown
Member

@riderx riderx commented Apr 14, 2026

Summary (AI generated)

  • sync Stripe customer names when an organization name changes
  • stop management email updates from overwriting the Stripe customer name
  • add a Bun backfill script to resync Stripe customer names from org names
  • add unit coverage for the new Stripe sync and rollback behavior

Motivation (AI generated)

Organization renames updated Capgo data but left Stripe customer names stale. That drift made billing records inconsistent and required manual cleanup for existing organizations.

Business Impact (AI generated)

This keeps billing data aligned with customer-facing organization records, reduces manual support work, and gives the team a safe bulk resync path for historical mismatches.

Test Plan (AI generated)

  • bunx vitest run tests/organization-put-stripe-sync.unit.test.ts tests/stripe-redirects.unit.test.ts
  • bunx eslint supabase/functions/_backend/public/organization/put.ts supabase/functions/_backend/utils/stripe.ts tests/organization-put-stripe-sync.unit.test.ts tests/stripe-redirects.unit.test.ts tests/organization-api.test.ts --no-warn-ignored
  • bunx eslint scripts/sync_stripe_org_names.ts --no-ignore
  • bun run supabase:with-env -- bunx vitest run tests/organization-api.test.ts -t "update organization" (blocked locally: Docker daemon/OrbStack not running, so Supabase could not start)

Generated with AI

Summary by CodeRabbit

  • New Features

    • Organization names now synchronize to Stripe when organization info is updated, with safeguards to restore prior state if related updates fail.
  • Chores

    • Added a maintenance utility to resynchronize existing organization names with Stripe (dry-run, apply, scoping, concurrency).
  • Bug Fix

    • Updating a customer's email no longer overwrites the Stripe customer name; email updates set only email and metadata.
  • Tests

    • Added and refined unit/integration tests covering name/email sync, rollback, and related flows.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 14, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a Bun/TypeScript bulk sync script to resynchronize Stripe customer name from organization records; updates Stripe utilities; modifies the org PUT handler to sanitize names, perform conditional Stripe name sync with optimistic-concurrency and rollback attempts on failure; and adds/updates unit and integration tests.

Changes

Cohort / File(s) Summary
Package + Script
package.json, scripts/sync_stripe_org_names.ts
Adds stripe:sync-org-names script and a Bun/TypeScript executable to bulk-sync Stripe customer name from org records; supports dry-run, scoping, paging, concurrency, env loading, and failure logging.
Organization PUT Handler
supabase/functions/_backend/public/organization/put.ts
Sanitizes incoming org name, passes sanitized name into update flow, applies optimistic-concurrency (.eq('name', ...) + maybeSingle()), and conditionally triggers updateCustomerOrganizationName for non-pending_ customers when the name changed. On Stripe failures after DB changes, attempts a DB rollback using the previous name and surfaces combined error details.
Stripe Utilities
supabase/functions/_backend/utils/stripe.ts
updateCustomerEmail now updates only email and metadata.email (no longer sets name); adds updateCustomerOrganizationName which updates Stripe customer name when Stripe is configured.
Tests — API
tests/organization-api.test.ts
Removes inline Stripe setup/teardown and customer_id injection from specific PUT organization API tests.
Tests — Unit (PUT handler)
tests/organization-put-stripe-sync.unit.test.ts
New Vitest suite verifying sanitized-name validation, successful Stripe sync, DB concurrency failures, Stripe failures with rollback (and rollback failure), and skipping sync for pending_ customer IDs. Mocks Supabase and Stripe interactions.
Tests — Stripe helpers
tests/stripe-redirects.unit.test.ts
Adds tests asserting updateCustomerEmail calls Stripe with { email, metadata: { email } } and updateCustomerOrganizationName calls Stripe with { name }.
Tests — Misc adjustments
tests/cli-min-version.test.ts, tests/device.test.ts, tests/events.test.ts
Various test setup and helper refinements: sequentialized seeding, bundle content helpers, channel upload adjustments, and improved flakiness handling.

Sequence Diagram(s)

sequenceDiagram
    actor Client
    participant Handler as PUT /organization Handler
    participant DB as Supabase Database
    participant Stripe as Stripe API

    Client->>Handler: PUT /organization (name)
    Handler->>DB: SELECT current org row (id, name, customer_id)
    DB-->>Handler: existing org

    Handler->>Handler: sanitize name
    alt customer_id exists & not pending_ & name changed
        Handler->>Stripe: customers.update(customer_id, { name: newName })
        Stripe-->>Handler: success/failure
    end

    Handler->>DB: UPDATE org SET name = newName (with .eq('name', oldName) / maybeSingle)
    alt DB update succeeds
        DB-->>Handler: OK
        Handler-->>Client: 200 + updated org
    else DB update fails
        DB-->>Handler: Error
        alt Stripe sync was attempted
            Handler->>Stripe: customers.update(customer_id, { name: oldName }) // rollback
            Stripe-->>Handler: rollback response
        end
        Handler-->>Client: Error (includes rollback status)
    end
Loading
sequenceDiagram
    actor Admin
    participant Script as sync_stripe_org_names.ts
    participant Env as Env Loader
    participant DB as Supabase Database
    participant Stripe as Stripe API
    participant FS as Local FS

    Admin->>Script: Run (args: --apply/--org-id/--limit/--concurrency)
    Script->>Env: load env file + Bun.env
    Script->>DB: Fetch target orgs (by org_id OR paginated where customer_id NOT NULL)
    DB-->>Script: list of {id, name, customer_id}
    Script->>Script: filter out empty names and pending_ customer_ids
    Script->>Script: split into batches & async pool (concurrency)

    par Parallel updates
        Script->>Stripe: customers.update(customer_id, { name: org.name })
        Stripe-->>Script: success/failure
    end

    Script->>Script: aggregate results
    alt failures found
        Script->>FS: write ./tmp/stripe_org_name_sync_failures.json
        Script-->>Admin: throw error / report failures
    else all succeed
        Script-->>Admin: report success count & samples
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

codex

Poem

🐰 I hopped through rows with careful care,

nudged Stripe names gently, here and there,
if DB stumbled I bounced them back,
logged my failures in a tidy stack,
now orgs and customers hum in pair.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.70% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: synchronizing Stripe organization names when org names change.
Description check ✅ Passed The PR description covers the summary, motivation, business impact, and test plan, addressing all required template sections with sufficient detail.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/stripe-org-name-sync

Comment @coderabbitai help to get the list of available commands and usage tips.

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq Bot commented Apr 14, 2026

Merging this PR will not alter performance

✅ 28 untouched benchmarks


Comparing codex/stripe-org-name-sync (dc726fd) with main (3b5f88d)

Open in CodSpeed

@riderx riderx marked this pull request as ready for review April 15, 2026 09:13
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 22424ff15e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread supabase/functions/_backend/public/organization/put.ts Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
tests/stripe-redirects.unit.test.ts (1)

379-420: Consider using it.concurrent() for parallel test execution.

These tests are independent and could run concurrently. As per coding guidelines, use it.concurrent() instead of it() when possible to maximize parallelism for faster CI/CD.

♻️ Suggested refactor
-  it('updates Stripe customer email without overwriting the organization name', async () => {
+  it.concurrent('updates Stripe customer email without overwriting the organization name', async () => {
-  it('updates Stripe customer name when the organization name changes', async () => {
+  it.concurrent('updates Stripe customer name when the organization name changes', async () => {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/stripe-redirects.unit.test.ts` around lines 379 - 420, Replace the two
independent tests that use it(...) with concurrent tests by changing it('updates
Stripe customer email without overwriting the organization name', ...) to
it.concurrent('updates Stripe customer email without overwriting the
organization name', ...) and it('updates Stripe customer name when the
organization name changes', ...) to it.concurrent('updates Stripe customer name
when the organization name changes', ...); keep the existing setup and
assertions (mocks for Stripe, updateCustomer, and imports of updateCustomerEmail
and updateCustomerOrganizationName) unchanged so tests run safely in parallel.
tests/organization-put-stripe-sync.unit.test.ts (1)

81-133: Consider using it.concurrent() for parallel test execution.

These tests reset mocks in beforeEach and are independent. Per coding guidelines, use it.concurrent() when possible to maximize CI/CD parallelism.

♻️ Suggested refactor
-  it('syncs Stripe customer name before updating the org row', async () => {
+  it.concurrent('syncs Stripe customer name before updating the org row', async () => {
-  it('rolls Stripe back when the database update fails', async () => {
+  it.concurrent('rolls Stripe back when the database update fails', async () => {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/organization-put-stripe-sync.unit.test.ts` around lines 81 - 133,
Replace the two independent tests that currently use it(...) with concurrent
execution by calling it.concurrent(...) for the specs titled "syncs Stripe
customer name before updating the org row" and "rolls Stripe back when the
database update fails"; update the two invocations that set up mocks via
supabaseClientMock, createOrgSelectBuilder and createOrgUpdateBuilder and the
assertions around put(...) and updateCustomerOrganizationNameMock to remain
unchanged so the tests run in parallel safely.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/sync_stripe_org_names.ts`:
- Around line 182-184: The filter chain that builds actionableOrgs calls
org.name.trim() unguarded and will throw if org.name is null; update the filter
on org.name to use a null-safe check such as optional chaining and a falsy guard
(e.g. org.name?.trim() and/or typeof check) so only non-empty string names pass.
Modify the second filter in actionableOrgs (the .filter(org =>
!!org.name.trim()) predicate) to safely handle null/undefined names before
calling trim.
- Around line 232-234: The write to FAILURE_OUTPUT may fail if its parent ./tmp/
directory doesn't exist; before calling Bun.write in the failures block (the
conditional that checks failures.length and calls Bun.write), ensure the
directory for FAILURE_OUTPUT exists by creating its parent directory (use
Bun.mkdir or equivalent with recursive:true) so the file write succeeds; update
the failures handling block around FAILURE_OUTPUT and Bun.write to create the
directory first, then perform the write and log.

---

Nitpick comments:
In `@tests/organization-put-stripe-sync.unit.test.ts`:
- Around line 81-133: Replace the two independent tests that currently use
it(...) with concurrent execution by calling it.concurrent(...) for the specs
titled "syncs Stripe customer name before updating the org row" and "rolls
Stripe back when the database update fails"; update the two invocations that set
up mocks via supabaseClientMock, createOrgSelectBuilder and
createOrgUpdateBuilder and the assertions around put(...) and
updateCustomerOrganizationNameMock to remain unchanged so the tests run in
parallel safely.

In `@tests/stripe-redirects.unit.test.ts`:
- Around line 379-420: Replace the two independent tests that use it(...) with
concurrent tests by changing it('updates Stripe customer email without
overwriting the organization name', ...) to it.concurrent('updates Stripe
customer email without overwriting the organization name', ...) and it('updates
Stripe customer name when the organization name changes', ...) to
it.concurrent('updates Stripe customer name when the organization name changes',
...); keep the existing setup and assertions (mocks for Stripe, updateCustomer,
and imports of updateCustomerEmail and updateCustomerOrganizationName) unchanged
so tests run safely in parallel.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 00933558-a7bb-49ac-8d91-a385f358f8ff

📥 Commits

Reviewing files that changed from the base of the PR and between d7ea9fd and 22424ff.

📒 Files selected for processing (7)
  • package.json
  • scripts/sync_stripe_org_names.ts
  • supabase/functions/_backend/public/organization/put.ts
  • supabase/functions/_backend/utils/stripe.ts
  • tests/organization-api.test.ts
  • tests/organization-put-stripe-sync.unit.test.ts
  • tests/stripe-redirects.unit.test.ts
💤 Files with no reviewable changes (1)
  • tests/organization-api.test.ts

Comment thread scripts/sync_stripe_org_names.ts Outdated
Comment thread scripts/sync_stripe_org_names.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/organization-put-stripe-sync.unit.test.ts (1)

111-133: Consider adding test coverage for failed rollback scenario.

This test validates the rollback scenario and correctly asserts that updateCustomerOrganizationName is called twice: first with the new name and then with the old name. However, the test mocks both calls to succeed, so it doesn't test what happens if either the forward update or the rollback update throws an error.

💡 Suggested additional test
it('includes both errors when rollback also fails', async () => {
  const selectBuilder = createOrgSelectBuilder({
    id: 'org-123',
    name: 'Old Name',
    customer_id: 'cus_123',
  })
  const updateBuilder = createOrgUpdateBuilder(null, { message: 'db write failed' })

  supabaseClientMock.mockReturnValue({
    from: vi.fn()
      .mockReturnValueOnce(selectBuilder)
      .mockReturnValueOnce(updateBuilder),
  })

  // First call succeeds, rollback call fails
  updateCustomerOrganizationNameMock
    .mockResolvedValueOnce(undefined)
    .mockRejectedValueOnce(new Error('Stripe rollback failed'))

  const error = await put(createContext(), {
    orgId: 'org-123',
    name: 'New Name',
  }, undefined).catch(caught => caught)

  expect(error).toBeInstanceOf(HTTPException)
  // Verify error contains both original and rollback error info
})
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/organization-put-stripe-sync.unit.test.ts` around lines 111 - 133, Add
a new unit test that simulates a failing DB update and a failing Stripe rollback
by reusing createOrgSelectBuilder and createOrgUpdateBuilder, mocking
supabaseClientMock to return those builders, then configuring
updateCustomerOrganizationNameMock to resolve once (forward update succeeds) and
reject once (rollback fails). Call the put(context, { orgId, name }, undefined)
and capture the thrown HTTPException, asserting it's an HTTPException and that
its message or nested error payload includes both the original DB error ("db
write failed") and the rollback error ("Stripe rollback failed") to ensure both
errors are surfaced by put.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/organization-put-stripe-sync.unit.test.ts`:
- Around line 111-133: Add a new unit test that simulates a failing DB update
and a failing Stripe rollback by reusing createOrgSelectBuilder and
createOrgUpdateBuilder, mocking supabaseClientMock to return those builders,
then configuring updateCustomerOrganizationNameMock to resolve once (forward
update succeeds) and reject once (rollback fails). Call the put(context, {
orgId, name }, undefined) and capture the thrown HTTPException, asserting it's
an HTTPException and that its message or nested error payload includes both the
original DB error ("db write failed") and the rollback error ("Stripe rollback
failed") to ensure both errors are surfaced by put.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 09784bab-a6e4-478b-9c0f-c26ae151cd39

📥 Commits

Reviewing files that changed from the base of the PR and between 22424ff and c62e001.

📒 Files selected for processing (3)
  • scripts/sync_stripe_org_names.ts
  • supabase/functions/_backend/public/organization/put.ts
  • tests/organization-put-stripe-sync.unit.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/sync_stripe_org_names.ts

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c62e001bef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/sync_stripe_org_names.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f08f0d73cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread supabase/functions/_backend/public/organization/put.ts Outdated
Comment thread supabase/functions/_backend/public/organization/put.ts Fixed
riderx and others added 2 commits April 15, 2026 12:15
…ariable'

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a888a8032b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread supabase/functions/_backend/public/organization/put.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f30947a7b0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread supabase/functions/_backend/public/organization/put.ts Outdated
Comment thread supabase/functions/_backend/public/organization/put.ts Fixed
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
supabase/functions/_backend/public/organization/put.ts (1)

213-247: Add request-scoped logs around the Stripe sync and rollback branches.

This path now contains multiple external writes and failure modes, but there is still no structured log tying them to a requestId. When rollback lookup/update fails, reconciling DB vs Stripe drift will be much harder than it needs to be.

As per coding guidelines, "All endpoints must receive Hono Context<MiddlewareKeyVariables> object and use c.get('requestId') for structured logging with cloudlog()".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@supabase/functions/_backend/public/organization/put.ts` around lines 213 -
247, Add structured, request-scoped logging (using c.get('requestId') and
cloudlog()) around the Stripe sync and rollback branches so every external write
and failure includes the requestId and context: log before calling
updateCustomerOrganizationName(c, ...), after success, and on error; log the
beginning and result of updateOrg(...) and include the expectedCurrentName
context; when catching errors and performing rollback, log the
getOrgForNameSync(...) lookup result/failure and the subsequent
updateCustomerOrganizationName(...) rollback attempt and failure, referencing
currentOrg, rollbackOrg, shouldUpdateStripeCustomerName and the original error
details so the cloud logs show requestId, operation, inputs and error messages
for easier reconciliation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@supabase/functions/_backend/public/organization/put.ts`:
- Around line 89-102: sanitizeOrgNameForSync currently returns whatever
strip_html RPC yields, but that can be empty/whitespace and later gets written
to orgs.name and Stripe; after calling supabase.rpc('strip_html') in
sanitizeOrgNameForSync validate the returned data by trimming it and rejecting
if it's empty (throw the existing simpleError with a clear error payload, e.g.,
error: 'sanitized_name_empty' or similar), otherwise return the trimmed
non-empty string so downstream code never receives a blank organization name.
- Around line 213-247: The current flow updates Stripe via
updateCustomerOrganizationName before committing the DB (updateOrg) and attempts
a best-effort rollback using getOrgForNameSync on error, which can race with
concurrent renames; change to drive Stripe updates from committed DB state
instead: remove the pre-commit call to updateCustomerOrganizationName(c, ...)
and instead perform the Stripe rename after updateOrg succeeds or, better, write
an outbox/event row (e.g., org name change record) inside the same transaction
used by updateOrg and have a separate reconciler/worker read that committed
outbox and call updateCustomerOrganizationName; ensure the reconciler uses the
DB’s canonical name and idempotent calls (and leverages expectedCurrentName/
customer_id checks) so concurrent renames cannot cause Stripe to be rolled back
to a stale name.

In `@tests/cli-min-version.test.ts`:
- Around line 109-120: The test is flaky because transient network failures
aren't retried for sdk calls and uploads; wrap the SDK calls (sdk.addChannel and
sdk.updateChannel that produce createChannelResult and linkSeedBundleResult) in
the same retry logic used elsewhere (or call the existing retry helper) so they
retry on transient "fetch failed" or network errors, and replace direct upload
calls referenced at lines like 163-167 and 201-208 with retryUpload (or the
shared retry wrapper) so assertions only run after a successful retried
operation.

---

Nitpick comments:
In `@supabase/functions/_backend/public/organization/put.ts`:
- Around line 213-247: Add structured, request-scoped logging (using
c.get('requestId') and cloudlog()) around the Stripe sync and rollback branches
so every external write and failure includes the requestId and context: log
before calling updateCustomerOrganizationName(c, ...), after success, and on
error; log the beginning and result of updateOrg(...) and include the
expectedCurrentName context; when catching errors and performing rollback, log
the getOrgForNameSync(...) lookup result/failure and the subsequent
updateCustomerOrganizationName(...) rollback attempt and failure, referencing
currentOrg, rollbackOrg, shouldUpdateStripeCustomerName and the original error
details so the cloud logs show requestId, operation, inputs and error messages
for easier reconciliation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 80c43ab3-8d1e-43ba-a31c-dbb36845f9e9

📥 Commits

Reviewing files that changed from the base of the PR and between f08f0d7 and bdc354a.

📒 Files selected for processing (6)
  • package.json
  • supabase/functions/_backend/public/organization/put.ts
  • tests/cli-min-version.test.ts
  • tests/device.test.ts
  • tests/events.test.ts
  • tests/organization-put-stripe-sync.unit.test.ts
✅ Files skipped from review due to trivial changes (2)
  • package.json
  • tests/organization-put-stripe-sync.unit.test.ts

Comment thread supabase/functions/_backend/public/organization/put.ts
Comment thread supabase/functions/_backend/public/organization/put.ts Outdated
Comment thread tests/cli-min-version.test.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b25aee9694

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread supabase/functions/_backend/public/organization/put.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7abb8dc4f2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread supabase/functions/_backend/public/organization/put.ts Outdated
Comment thread supabase/functions/_backend/public/organization/put.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 74ace57c44

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread supabase/functions/_backend/public/organization/put.ts
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd2155d047

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread supabase/functions/_backend/utils/stripe.ts
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c11056a565

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread supabase/functions/_backend/public/organization/put.ts Outdated
@sonarqubecloud
Copy link
Copy Markdown

@riderx riderx merged commit a6bf32a into main Apr 15, 2026
15 checks passed
@riderx riderx deleted the codex/stripe-org-name-sync branch April 15, 2026 15:31
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.

2 participants