Repository navigation
acc: record that null values for number template properties panic - #8154
Conversation
bundle init crashes with a nil-pointer panic in the JSON schema type check when a property of type number gets null, from --config-file or from the template schema's enum, and when an integer property that only a root anyOf schema declares gets null from --config-file. A null for a top-level integer property fails cleanly. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Regression test report ✅Commit: Selected 1 changed tests (limit=20, 0 not selected) 2 tests: regression=0 unreleased=0 coverage=2 failing=0
|
✅ Integration test reportCommit: 619e881
Top 6 slowest tests (at least 2 minutes):
|
There was a problem hiding this comment.
Automated review at a51b35b. Each finding was verified against the code.
No blocking issues found. 2 non-blocking comment(s) below.
This PR adds an acceptance test that records how bundle init handles JSON null for template properties. Three cases hit the nil reflect.TypeOf panic in validateNumber/validateInteger, and one is a clean integer error included for contrast. The fixtures and golden output match the current code paths. Two things are worth changing: the expected failures should use musterr, and the anyOf case can't tell a null apart from a valid integer.
Sankalp-Mittal
left a comment
There was a problem hiding this comment.
[AI Generated] Review by review-factory (Claude Opus 5.5 + Claude Opus 5.5 + Claude Sonnet 5.5, cross-verified). Only points the reviewers agreed on are posted.
No blocking or major issues found.
… integer rejection Co-authored-by: Isaac <no-reply@databricks.com>
Sankalp-Mittal
left a comment
There was a problem hiding this comment.
[AI Generated] Follow-up review by review-factory (Claude Opus 5.5 + Claude Opus 5.5 + Claude Sonnet 5.5, cross-verified). Only points the reviewers agreed on are posted.
Earlier findings: 1 still open.
No new issues found.
Changes
New test acceptance/bundle/templates-machinery/null-value: custom templates initialized non-interactively with
bundle init, recording what happens when a property gets a JSONnull:--config-filewith{"ratio": null}for anumberproperty: the CLI panics (runtime error: invalid memory address or nil pointer dereference).--config-filewith{"count": null}for anintegerproperty: a clean error (failed to parse property count: cannot convert <nil> to an integer), included for contrast."enum": [0.5, null]on anumberproperty: panics while loading the schema.--config-filewith{"extra": null}, whereextrais anintegerproperty that the schema's only rootanyOfalternative declares: panics.--config-filewith{"extra": 3}for the same property: rejected withinstance does not match any of the schemas in anyOf, although 3 is a valid integer.LoadInstanceconverts only root-level integer properties from float64, so an integer declared only inanyOffails for every value. This is a separate bug; the case shows that the null case's error after the fix is not specific to null.Every command is expected to fail, so the script asserts it with
musterr. It drops the stack frames afterStack Trace:because they depend on the build, as acceptance/panic does. Badness in test.toml describes the wrong behavior and the expected one.Cause:
validateNumberandvalidateIntegerin libs/jsonschema/validate_type.go callreflect.TypeOf(v).Kind(), andreflect.TypeOf(nil)returns a nilreflect.Type. For top-level integer propertiestoIntegerrejects nil first, which is why only theanyOfpath reaches the integer validator with a nil value.Why
This PR was created by analyzing coverage gaps. Coverage: http://go/cli/dashboard/coverage/file/libs/jsonschema/validate_type.go (validateNumber and validateInteger, lines 33-51: unit tests cover them, but no test passes a null).
This is a new small test next to the other templates-machinery tests, since none of them sends a null. Runtime is about 0.05s per variant (DMS matrix inherited from acceptance/bundle, 2 variants).
Fix: #8155
Gaps and risks
musterr.🤖 AI agent (opus5.5, isaac_claude)
This pull request and its description were written by Isaac.