Skip to content

[wrangler] Add hyperdrive planetscale integrations commands - #15065

Open
mtlemilio wants to merge 1 commit into
cloudflare:mainfrom
mtlemilio:hyperdrive-create-planetscale-database
Open

[wrangler] Add hyperdrive planetscale integrations commands#15065
mtlemilio wants to merge 1 commit into
cloudflare:mainfrom
mtlemilio:hyperdrive-create-planetscale-database

Conversation

@mtlemilio

@mtlemilio mtlemilio commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #SQC-896.

In June we released an evolution to our partnership with PlanetScale: https://developers.cloudflare.com/changelog/post/2026-06-18-planetscale-databases-cloudflare-billing/

From the UI customers can create PlanetScale databases that are billed to their Cloudflare account. This change in Wrangler allows us to integrate the Wrangler CLI with the PlanetScale CLI by passing the relevant credentials. This supports an agentic/CLI workflow, in addition to the UI based flow that is currently available.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because:

A picture of a cute animal (not mandatory, but encouraged)


Open in Devin Review

@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: db698fc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
wrangler Minor
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment on lines +190 to +202
export async function createDatabaseSignature(
config: Config,
integration: string
): Promise<CreateDatabaseSignature> {
const accountId = await requireAuth(config);
return await fetchResult(
config,
`/accounts/${accountId}/hyperdrive/integrationsOperations/${integration}/createDatabaseSignature`,
{
method: "POST",
}
);
}

@devin-ai-integration devin-ai-integration Bot Aug 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 New Hyperdrive API call bypasses the required Cloudflare SDK

The new signing request talks to the Cloudflare API by hand-building a URL and calling the raw REST endpoint (fetchResult at packages/wrangler/src/hyperdrive/client.ts:195-201) instead of the official Cloudflare TypeScript SDK that the repository requires for all API access, so the call is untyped and can rely on undocumented endpoints.
Impact: Contributors reading the code get an unsupported pattern, and API changes will not be caught by types.

Repository rule and current code path

The root AGENTS.md anti-patterns list states: "Direct Cloudflare REST API calls → use the Cloudflare TypeScript SDK", and packages/wrangler/CONTRIBUTING.md ("Integration with Cloudflare REST API") repeats that the SDK, set up for every command handler, should be preferred. The new createDatabaseSignature() builds /accounts/${accountId}/hyperdrive/integrationsOperations/${integration}/createDatabaseSignature and posts via fetchResult. Note the rest of packages/wrangler/src/hyperdrive/client.ts predates the rule and uses the same pattern, so this may be an accepted deviation if the endpoint is not exposed by the SDK.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The underlying API endpoint hasn't been released yet. But when it is, we will update this code to use the generated Typescript SDK.

@workers-devprod
workers-devprod requested review from a team and penalosa and removed request for a team August 6, 2026 17:28
@workers-devprod

workers-devprod commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/hyperdrive-planetscale.md: [@cloudflare/wrangler]
  • packages/workers-utils/src/environment-variables/factory.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/hyperdrive.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/hyperdrive/client.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/hyperdrive/planetscale.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/index.ts: [@cloudflare/wrangler]

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Aug 6, 2026
@mtlemilio
mtlemilio force-pushed the hyperdrive-create-planetscale-database branch from 57644b4 to 9ff71ef Compare August 11, 2026 16:38
devin-ai-integration[bot]

This comment was marked as resolved.

@mtlemilio
mtlemilio force-pushed the hyperdrive-create-planetscale-database branch from 9ff71ef to 9a061c5 Compare August 11, 2026 17:08
devin-ai-integration[bot]

This comment was marked as resolved.

@mtlemilio
mtlemilio force-pushed the hyperdrive-create-planetscale-database branch from 9a061c5 to 1580278 Compare August 11, 2026 19:22
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/hyperdrive-planetscale.md: [@cloudflare/wrangler]
  • packages/workers-utils/src/environment-variables/factory.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/hyperdrive.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/hyperdrive/client.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/hyperdrive/planetscale.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/index.ts: [@cloudflare/wrangler]

@mtlemilio mtlemilio changed the title [wrangler] Add hyperdrive planetscale signature command [wrangler] Add hyperdrive planetscale integrations commands Aug 11, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 11, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@15065

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15065

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15065

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@15065

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@15065

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@15065

miniflare

npm i https://pkg.pr.new/miniflare@15065

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15065

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@15065

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@15065

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@15065

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@15065

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@15065

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@15065

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@15065

wrangler

npm i https://pkg.pr.new/wrangler@15065

commit: db698fc

@mtlemilio
mtlemilio force-pushed the hyperdrive-create-planetscale-database branch from 1580278 to 380a64f Compare August 11, 2026 21:44
@mtlemilio
mtlemilio force-pushed the hyperdrive-create-planetscale-database branch from 380a64f to db698fc Compare August 11, 2026 23:41

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Comment on lines +113 to +116
async handler(_args, { config }) {
const signature = await createDatabaseSignature(config, "planetScale");
logger.log(JSON.stringify(signature, null, 2));
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Standalone authorization output can include extra fields that the PlanetScale tool rejects

The whole server response is printed verbatim (JSON.stringify(signature, null, 2) at packages/wrangler/src/hyperdrive/planetscale.ts:115) instead of only the three fields the PlanetScale tool accepts, so the documented pipe workflow breaks the moment the server returns any additional field.
Impact: Users following the documented piping instructions can hit a hard failure and be unable to create a database.

Inconsistency with the create path's defensive serialization

The create path deliberately rebuilds the payload field-by-field (packages/wrangler/src/hyperdrive/planetscale.ts:135-142) with the comment that "the PlanetScale CLI rejects unknown fields, so an added response field would otherwise break database creation". The signature command, whose documented purpose is exactly wrangler hyperdrive planetscale signature | pscale database create <name> --cloudflare-billing @- (see .changeset/hyperdrive-planetscale.md:26-29), dumps whatever createDatabaseSignature (packages/wrangler/src/hyperdrive/client.ts:190-201) returned, including any future/extra fields. The two paths should serialize identically.

Suggested change
async handler(_args, { config }) {
const signature = await createDatabaseSignature(config, "planetScale");
logger.log(JSON.stringify(signature, null, 2));
},
async handler(_args, { config }) {
const signature = await createDatabaseSignature(config, "planetScale");
logger.log(
JSON.stringify(
{
account_id: signature.account_id,
timestamp: signature.timestamp,
signature: signature.signature,
},
null,
2
)
);
},
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants