netlify / netlifyctl

MIT License
176 stars 34 forks source link

some styles of header definition (to add to a redirect) do not work as expected in netlify.toml (only when parsed by netlifyctl) #102

Closed depadiernos closed 6 years ago

depadiernos commented 6 years ago

CONTEXT: Unable to use the following in a netlify.toml file:

[[redirects]]
  from = "/map"
  to = "https://maps.google.com"
  status = 200
  force = true
  headers = {X-From = "netlify_live", x-api-key= "LIVE API KEY"}

This causes the following error when running netlifyctl deploy

"Near line 13 (last key parsed 'redirects.headers'): Expected value but found '{' instead."

WORKAROUND:

The following format, however, works:

[[redirects]]
  from = "/calculator/test"
  to = "https://futuregerald-requestbin.herokuapp.com/pzyoldpz"
  status = 200
  force = true
  [redirects.headers]
    X-From = "netlify_test"
    x-api-key= "TEST API KEY"
fool commented 6 years ago

Did you determine if a single header defined this way works @depadiernos ? Is the bug limited to multiple?

depadiernos commented 6 years ago

@fool The bug is not limited to multiple. Even with a single header, the deploy will fail. The following will fail also:

[[redirects]]
  from = "/map"
  to = "https://maps.google.com"
  status = 200
  force = true
  headers = {X-From = "netlify_live"}
brycekahle commented 6 years ago

The TOML parser we use only supports version 0.2.0 of the TOML spec. Inline tables were added in 0.4.0.

fool commented 6 years ago

Thanks @brycekahle ! That also explains https://github.com/netlify/bitballoon/issues/1469 !

brycekahle commented 6 years ago

I was referencing the TOML parser we have in netlifyctl. I'm not sure what the origin uses. We should make sure they match though.