Skip to content

Default openapi.addSpec credentialTargetScope to the source's scope#747

Merged
RhysSullivan merged 1 commit intomainfrom
rs/fix-addspec-credential-target-scope
May 10, 2026
Merged

Default openapi.addSpec credentialTargetScope to the source's scope#747
RhysSullivan merged 1 commit intomainfrom
rs/fix-addspec-credential-target-scope

Conversation

@RhysSullivan
Copy link
Copy Markdown
Owner

Summary

addSpecInternal forwarded credentialTargetScope to rebuildSource unchanged. When the caller (notably config-sync, which never sets it) passed undefined, targetScopeForBinding errored with "credentialTargetScope is required when adding direct OpenAPI credentials" — so any OpenAPI source with a header secret in executor.jsonc broke the daemon at startup.

Default to config.scope, matching the pattern already used by:

  • refreshSource (packages/plugins/openapi/src/sdk/plugin.ts:972 — hardcodes scope)
  • editSource (packages/plugins/openapi/src/sdk/plugin.ts:1090input.credentialTargetScope ?? scope)

Repro (before this PR)

// executor.jsonc
{
  "sources": [
    {
      "kind": "openapi",
      "spec": "https://raw.githubusercontent.com/cloudflare/api-schemas/main/openapi.json",
      "namespace": "cloudflare_api",
      "headers": {
        "Authorization": { "value": "secret-public-ref:...", "prefix": "Bearer " }
      }
    }
  ]
}
$ executor web
[config-sync] Failed to load source "cloudflare_api":
  OpenApiOAuthError: credentialTargetScope is required when adding direct OpenAPI credentials

Test plan

  • New regression test in plugin.test.ts: addSpec without credentialTargetScope defaults to the source's scope — fails on main, passes after the fix
  • Full openapi plugin suite: 90 tests pass (was 89)
  • bun run lint clean

config-sync calls openapi.addSpec without ever passing
credentialTargetScope. addSpecInternal forwarded the field unchanged
to rebuildSource, where targetScopeForBinding rejected the missing
field with "credentialTargetScope is required when adding direct
OpenAPI credentials" — so any source with a header secret in
executor.jsonc broke the daemon at startup.

Fall back to config.scope, matching what refreshSource and editSource
already do (refreshSource hardcodes scope; editSource uses
input.credentialTargetScope ?? scope). Add a regression test that
exercises addSpec with header secrets but no credentialTargetScope —
the test fails on main and passes after the fix.
@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 75a4714 Commit Preview URL

Branch Preview URL
May 10 2026, 05:02 PM

@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 Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud 75a4714 May 10 2026, 05:02 PM

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 10, 2026

Open in StackBlitz

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@747

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@747

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@747

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@747

@executor-js/storage-core

npm i https://pkg.pr.new/@executor-js/storage-core@747

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@747

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@747

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@747

@executor-js/plugin-google-discovery

npm i https://pkg.pr.new/@executor-js/plugin-google-discovery@747

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@747

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@747

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@747

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@747

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@747

executor

npm i https://pkg.pr.new/executor@747

commit: 75a4714

@RhysSullivan RhysSullivan merged commit 3afa88a into main May 10, 2026
10 checks passed
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