Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

petebacondarwin
Copy link
Contributor

@petebacondarwin petebacondarwin commented Dec 5, 2024

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
Copy link

changeset-bot bot commented Dec 5, 2024

🦋 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 e2e Run e2e tests on a PR 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
@@ -54,41 +55,60 @@ describe("versions secret put", () => {
expect(std.err).toMatchInlineSnapshot(`""`);
});

// For some reason, this always hangs. Not sure why
Copy link
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().

@@ -82,8 +82,12 @@ export function mockGetVersion(versionInfo?: VersionDetails) {
function mockGetVersionContent() {
msw.use(
http.get(
`*/accounts/:accountId/workers/scripts/:scriptName/content/v2?version=ce15c78b-cc43-4f60-b5a9-15ce4f298c2a`,
Copy link
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.

Copy link
Contributor

github-actions bot commented Dec 5, 2024

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.


[email protected] 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
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.

Copy link
Contributor

@andyjessop andyjessop left a comment

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!

@@ -75,21 +75,22 @@ export function readConfig(
configPath: string | undefined,
// Include command specific args as well as the wrangler global flags
args: ReadConfigCommandArgs,
requirePagesConfig: true
options: { requirePagesConfig: true }
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -75,6 +75,18 @@ describe("versions secret put", () => {
expect(std.err).toMatchInlineSnapshot(`""`);
});

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
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
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
31 of 32 checks passed
@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
penalosa pushed a commit that referenced this pull request Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e tests on a PR
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants