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: normalise account_id = '' to account_id: undefined #1365

Merged
merged 1 commit into from
Jun 28, 2022

Conversation

threepointone
Copy link
Contributor

Disable whitespace for this review!


In older templates, (i.e made for wrangler 1.x), account_id ='' is considered as a valid input, but then ignored. With wrangler 2, when running wrangler dev, we log an error, but it fixes itself after we get an account id. Much like #1329, the fix here is to normalise that value when we see it, and replace it with undefined while logging a warning.

This fix also tweaks the messaging for a blank route value to suggest some user action.

In older templates, (i.e made for wrangler 1.x), `account_id =''` is considered as a valid input, but then ignored. With wrangler 2, when running wrangler dev, we log an error, but it fixes itself after we get an account id. Much like #1329, the fix here is to normalise that value when we see it, and replace it with `undefined` while logging a warning.

This fix also tweaks the messaging for a blank route value to suggest some user action.
@changeset-bot
Copy link

changeset-bot bot commented Jun 28, 2022

🦋 Changeset detected

Latest commit: 78e208e

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

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

@github-actions
Copy link
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.developers.workers.dev/runs/2577572179/npm-package-wrangler-1365

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

npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/1365/npm-package-wrangler-1365

Or you can use npx with this latest build directly:

npx https://prerelease-registry.developers.workers.dev/runs/2577572179/npm-package-wrangler-1365 dev path/to/script.js

Copy link
Contributor

@JacobMGEvans JacobMGEvans left a comment

Choose a reason for hiding this comment

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

We should have further discussions internally pertaining to null vs. undefined vs values like[ ]
Cc: @petebacondarwin

This isn't blocking and my question for messaging is also non-blocking

Comment on lines +697 to +698
diagnostics: Diagnostics,
rawEnv: RawEnvironment
Copy link
Contributor

Choose a reason for hiding this comment

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

This a convention?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see that it's common we are passing diagnostics first.

): RawEnvironment {
if (rawEnv["route"] === "") {
diagnostics.warnings.push(
`Route assignment ${JSON.stringify(rawEnv["route"])} will be ignored.`
`The "route" field in your configuration is an empty string and will be ignored.\n` +
`Please remove the "route" field from your configuration.`
Copy link
Contributor

Choose a reason for hiding this comment

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

Allowing the empty string, then asking them to remove the field seems ambivalent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's more actionable than just saying it'll be ignored, this gives them an action to take to remove the warning.
It'll happen when they use an older project or template. We'll have a go at cleaning up the templates when we work on generate, but we should also give actionable advice.

@threepointone threepointone merged commit b9f7200 into main Jun 28, 2022
@threepointone threepointone deleted the normalise-account-id branch June 28, 2022 16:37
@github-actions github-actions bot mentioned this pull request Jun 28, 2022
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.

2 participants