build icon indicating copy to clipboard operation
build copied to clipboard

Validate invalid case for configuration properties

Open ehmicky opened this issue 4 years ago • 0 comments

Problem

@netlify/config validates configuration properties. For example, the following is valid:

[context.production]
command = "test" 

But the following is invalid (context should not be a string) and will be reported as a user error:

context = "production"

However, this validation is based on the case-sensitive configuration property name. Since unknown properties are passed through, the following is not validated:

CONTEXT = " production"

This can be a problem in production when the buildbot tries to parse @netlify/config return value. In that case, it relies on definitions inside netlify-commons, which are case-insensitive instead. This will result in a system error reported as:

json: cannot unmarshal string into Go struct field Resolved.Config.context of type map[string]ntoml.DeployContext

Example build logs

Solution

A possible solution to this problem would be to fail builds in @netlify/config with a user error when a configuration property is using the wrong case.

@netlify/config currently allows (and normalizes) using a Capitalized case for build and most build.* properties.

We would want to do this incrementally to avoid breaking sites:

  • Print a warning message
  • Post a community warning with a 2 weeks notice
  • Then fail builds using wrong case for configuration properties

ehmicky avatar Jun 29 '21 19:06 ehmicky