The func.yaml JSON schema is generated with github.com/alecthomas/jsonschema. Its number-keyword handling stores minimum/maximum as int (Type.Minimum int, reflect.go:60) and parses the tag value with strconv.Atoi — for both the jsonschema tag (numbericKeywords, reflect.go:614) and the jsonschema_extras tag (extraKeywords). A fractional minimum such as 0.01 fails to parse, the error is discarded, and the emitted schema gets minimum: 0.
As a result, schema-based validation is looser than the runtime ValidateScale. For example scale.kpa.target requires >= 0.01 at runtime, but the generated schema only enforces > 0 (via an exclusiveMinimum: true workaround), so a value like 0.001 passes the published schema/func_yaml-schema.json while ValidateScale rejects it at deploy time.
This is a pre-existing, generator-wide limitation affecting any fractional minimum (not specific to the scale fields): the library simply cannot express a non-integer minimum.
Possible fixes
- Post-process the generated schema in
schema/generator/main.go to set fractional minima after reflection (targeted, but per-field).
- Switch to a jsonschema library / tag path that supports float minima, then regenerate
schema/func_yaml-schema.json so schema validation matches ValidateScale.
Context
Surfaced by the Copilot review of #4063:
#4063 (comment)
The func.yaml JSON schema is generated with
github.com/alecthomas/jsonschema. Its number-keyword handling storesminimum/maximumasint(Type.Minimum int, reflect.go:60) and parses the tag value withstrconv.Atoi— for both thejsonschematag (numbericKeywords, reflect.go:614) and thejsonschema_extrastag (extraKeywords). A fractional minimum such as0.01fails to parse, the error is discarded, and the emitted schema getsminimum: 0.As a result, schema-based validation is looser than the runtime
ValidateScale. For examplescale.kpa.targetrequires>= 0.01at runtime, but the generated schema only enforces> 0(via anexclusiveMinimum: trueworkaround), so a value like0.001passes the publishedschema/func_yaml-schema.jsonwhileValidateScalerejects it at deploy time.This is a pre-existing, generator-wide limitation affecting any fractional
minimum(not specific to the scale fields): the library simply cannot express a non-integerminimum.Possible fixes
schema/generator/main.goto set fractional minima after reflection (targeted, but per-field).schema/func_yaml-schema.jsonso schema validation matchesValidateScale.Context
Surfaced by the Copilot review of #4063:
#4063 (comment)