Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Provide helpful error when user accidentally puts kv-namespace information under [site] #937

Merged
merged 3 commits into from
Dec 12, 2019

Conversation

gabbifish
Copy link
Contributor

@gabbifish gabbifish commented Dec 7, 2019

This PR closes #798.

If someone provides a wrangler.toml with

account_id = "c2c4de4232cdae687dc7a4a0323df63a"
name = "butt"
type = "webpack"
route = ""
workers_dev = true
zone_id = ""

[site]
bucket = "./public"
entry-point = "workers-site"

kv-namespaces = [
         { binding = "BUTTS", id = "4197135817e648c1957dcc6c3fc3d462" }
]

we now provide an error message on any wrangler command:

Error: kv-namespaces should not live under the [site] table in wrangler.toml; please move it above [site].

I wanted to set up TOML serialization so that [site] would be an inline TOML table (so there would be no reasonable way to put kv-namespaces within site!) but alas, inline TOML table serialization isn't supported by the serde TOML serializer yet.

let manifest: Manifest = match config.try_into() {
Ok(m) => m,
Err(e) => {
if e.to_string().contains("unknown field `kv-namespaces`") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if there's a nicer way to match on the specific error thrown by serde when the #[serde(deny_unknown_fields)] condition is triggered, I'm all ears!

Copy link
Contributor

@EverlastingBugstopper EverlastingBugstopper left a comment

Choose a reason for hiding this comment

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

this looks good to me after conflicts are addressed :)

@gabbifish gabbifish merged commit 2e45071 into master Dec 12, 2019
@gabbifish gabbifish deleted the gabbi/fix-#798 branch December 12, 2019 01:05
ashleymichal pushed a commit that referenced this pull request Dec 13, 2019
…ation under [site] (#937)

* Provide helpful error when user accidentally puts kv-namespace information under [site]

* improve error messaging
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Direct users to add kv-namespaces to specific portion of toml
4 participants