Skip to content

Don't 500 on listSourceBindings after source removal#515

Merged
RhysSullivan merged 1 commit intomainfrom
fix/openapi-bindings-after-source-removed
May 4, 2026
Merged

Don't 500 on listSourceBindings after source removal#515
RhysSullivan merged 1 commit intomainfrom
fix/openapi-bindings-after-source-removed

Conversation

@RhysSullivan
Copy link
Copy Markdown
Owner

@RhysSullivan RhysSullivan commented May 4, 2026

Summary

  • When a user deletes an OpenAPI source, sourceWriteKeys invalidates the React openApiSourceBindingsAtom (rendered via OpenApiSourceSummary / EditOpenApiSource). The atom revalidates before unmount, calls listSourceBindings, and the store's validateBindingTarget threw StorageError("source does not exist") — surfacing to the browser as a 500 and a Sentry alert (NODE-CLOUDFLARE-WORKERS-39).
  • A removed source has no bindings, so reads should return [] / null rather than throw. Writes still need to reject.
  • Fix: split validateBindingTarget into a scope-stack-only validateBindingScopes used by listSourceBindings and resolveSourceBinding; keep the existence check on the write paths (setSourceBinding, removeSourceBinding).

Test plan

  • pnpm vitest run in packages/plugins/openapi — 72/72 passing
  • New regression test: listSourceBindings returns [] for a removed source

When the React openApiSourceBindingsAtom revalidates after a source
delete (sourceWriteKeys invalidate it before the page unmounts), the
store threw StorageError because validateBindingTarget required the
source row to exist. That surfaced to the browser as a 500 / Sentry
alert even though the delete itself succeeded.

Split validateBindingTarget into a scope-stack-only validator used by
reads (listSourceBindings, resolveSourceBinding) and the original used
by writes (setSourceBinding, removeSourceBinding). A removed source
now reads back as [] / null; writes still reject as before.
@RhysSullivan RhysSullivan merged commit 9340eb8 into main May 4, 2026
5 of 7 checks passed
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing abd0769 Commit Preview URL

Branch Preview URL
May 04 2026, 05:58 PM

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