Skip to content

fix: ensure that version secrets commands do not write wrangler config warnings#7450

Merged
petebacondarwin merged 1 commit into
mainfrom
pbd/fixup-versions-commands
Dec 5, 2024
Merged

fix: ensure that version secrets commands do not write wrangler config warnings#7450
petebacondarwin merged 1 commit into
mainfrom
pbd/fixup-versions-commands

Conversation

@petebacondarwin

@petebacondarwin petebacondarwin commented Dec 5, 2024

Copy link
Copy Markdown
Contributor

Fixes #0000

Ensures that version secrets commands do not write wrangler config warnings.
This was a regression introduced by #7437.


  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: bug fix

@petebacondarwin petebacondarwin requested review from a team as code owners December 5, 2024 12:27
@changeset-bot

changeset-bot Bot commented Dec 5, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a80fb2c

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

This PR includes changesets to release 2 packages
Name Type
wrangler 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

@petebacondarwin petebacondarwin added the ci:e2e Run wrangler + vite-plugin E2E tests on a pull request label Dec 5, 2024
@petebacondarwin petebacondarwin force-pushed the pbd/fixup-versions-commands branch from 5a9a2e4 to a80fb2c Compare December 5, 2024 12:30
@petebacondarwin petebacondarwin changed the title Pbd/fixup-versions-commands fix: ensure that version secrets commands do not write wrangler config warnings Dec 5, 2024
expect(std.err).toMatchInlineSnapshot(`""`);
});

// For some reason, this always hangs. Not sure why

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.

This was broken because you cannot call useMockStdin() from within an it() clause since itself calls things like beforeEach().

function mockGetVersionContent() {
msw.use(
http.get(
`*/accounts/:accountId/workers/scripts/:scriptName/content/v2?version=ce15c78b-cc43-4f60-b5a9-15ce4f298c2a`,

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.

This was causing MockServiceWorkers (MSW) to write warnings to the console about a redundant query in the URL matcher.

@github-actions

github-actions Bot commented Dec 5, 2024

Copy link
Copy Markdown
Contributor

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12179779644/npm-package-wrangler-7450

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/7450/npm-package-wrangler-7450

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12179779644/npm-package-wrangler-7450 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12179779644/npm-package-create-cloudflare-7450 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12179779644/npm-package-cloudflare-kv-asset-handler-7450
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12179779644/npm-package-miniflare-7450
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12179779644/npm-package-cloudflare-pages-shared-7450
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12179779644/npm-package-cloudflare-vitest-pool-workers-7450
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12179779644/npm-package-cloudflare-workers-editor-shared-7450
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12179779644/npm-package-cloudflare-workers-shared-7450
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12179779644/npm-package-cloudflare-workflows-shared-7450

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.92.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20241106.2
workerd 1.20241106.2 1.20241106.2
workerd --version 1.20241106.2 2024-11-06

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

Comment on lines 8 to +9
const configPath =
args.config || (args.name && findWranglerConfig(path.dirname(args.name)));
return readConfig(configPath, args);
args.config || (entryPath && findWranglerConfig(path.dirname(entryPath)));

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.

In the future I think we could somehow roll this into readConfig() itself and remove the need for this helper function at all.

@andyjessop andyjessop 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.

Looks great, nice cleanup too. Thanks!

// Include command specific args as well as the wrangler global flags
args: ReadConfigCommandArgs,
requirePagesConfig: true
options: { requirePagesConfig: true }

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.

👍


test("no wrangler configuration warnings shown", async () => {
await writeFile("secrets.json", JSON.stringify({ SECRET_1: "secret-1" }));
await writeFile("wrangler.json", JSON.stringify({ invalid_field: true }));

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.

Nit, but could this use the writeWranglerConfig helper?

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.

Not really because that requires that the input object matches the RawConfig type, which then requires an awkward cast.

@petebacondarwin petebacondarwin merged commit 8c873ed into main Dec 5, 2024
@petebacondarwin petebacondarwin deleted the pbd/fixup-versions-commands branch December 5, 2024 14:30
@workers-devprod workers-devprod mentioned this pull request Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:e2e Run wrangler + vite-plugin E2E tests on a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants