Wrangler: "expected a table key" error when configuring vars on wrangler.toml

Created on 23 Mar 2020  路  5Comments  路  Source: cloudflare/wrangler

馃悰 Bug Report

According to the docs this is how vars should be defined:

vars = {
  FOO = "0f2ac74b498b48028cb68387c421e279",
  BAR = "068c101e168d03c65bddf4ba75150fb0"
}

https://developers.cloudflare.com/workers/tooling/wrangler/configuration

But this produces the error:

Error: expected a table key, found a newline at line 7 column 9 in wrangler.toml

Putting everything in a single line solves it... but it's pretty ugly.

vars = { FOO = "0f2ac74b498b48028cb68387c421e279", BAR = "068c101e168d03c65bddf4ba75150fb0"}

Environment

  • operating system: macOS
  • output of node -v: v12.16.1
  • output of wrangler -V: wrangler 1.8.1
user report

Most helpful comment

@delphaber you'll need to define like so

[env.staging.vars]
FOO = "bar"

[env.production.vars]
FOO = "baz"

the error you're seeing is because your TOML is invalid - you can copy and paste your toml file here and see that it gives you a very similar error

All 5 comments

Hey @PierBover - there are two different ways to define tables in TOML, the one described in the docs is the inline style.

If you want to have them on multiple lines you should be able to follow this also valid style:

[vars]
FOO = "1234"
BAR = "5678"

Thanks @EverlastingBugstopper !

You should probably update those docs though...

But it seems not working when using environments :(

[env.staging]
  [vars]
    FOO = "bar"

[env.production]
  [vars]
    FOO = "baz"
$ wranger build -e staging
# Error: redefinition of table `vars` for key `vars` at line XX column X in wrangler.toml

@delphaber you'll need to define like so

[env.staging.vars]
FOO = "bar"

[env.production.vars]
FOO = "baz"

the error you're seeing is because your TOML is invalid - you can copy and paste your toml file here and see that it gives you a very similar error

Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adaptive picture adaptive  路  5Comments

EverlastingBugstopper picture EverlastingBugstopper  路  3Comments

xtuc picture xtuc  路  5Comments

shyim picture shyim  路  5Comments

nickbalestra picture nickbalestra  路  5Comments