Repository navigation
Return an error instead of panicking on a null property schema in a template - #8168
Conversation
59ff7e1 to
27d86da
Compare
Regression test report ✅Commit: Selected 1 changed tests (limit=20, 0 not selected) 2 tests: regression=2 unreleased=0 coverage=0 failing=0
TestAccept/bundle/templates-machinery/null-property-schema/DMS=: branch ✅ | main (d164fcc) ❌ | latest (v1.28.0) ❌main (d164fcc): latest (v1.28.0): TestAccept/bundle/templates-machinery/null-property-schema/DMS=true: branch ✅ | main (d164fcc) ❌ | latest (v1.28.0) ❌main (d164fcc): latest (v1.28.0): |
✅ Integration test reportCommit: 1eff7db
Top 3 slowest tests (at least 2 minutes):
|
27d86da to
4d3ef78
Compare
There was a problem hiding this comment.
Automated review at 4d3ef78. Each finding was verified against the code.
Not ready yet: 1 open question(s) about a change users could be hurt by.
This PR makes LoadFS return an error naming the property when a template schema has a property set to JSON null, so bundle init no longer panics. It fixes both crashes in the acceptance test: a null at the root and a null in a root anyOf branch. I found no concrete defect. The open question is how far the recursive walk goes: it also rejects null properties under oneOf, items and a property's own properties. No code reads those today, so templates that work on base would stop loading.
Questions
- [blocking] Your description says a null nested anywhere "panics as soon as that branch is evaluated", but some of these branches are never evaluated.
ValidateInstance(instance.go) has nooneOfvalidator, and nothing in instance.go or libs/template/config.go readsItems. Every validator also only loops overs.Propertiesof the schema it is called on, never over a property's ownproperties. So{"oneOf": [{"properties": {"p": null}}]}or a nested"properties": {"p": null}under a string property works withbundle initon base, and with this change it fails withfailed to load schema. Should the walk stop at the paths that are actually dereferenced (rootproperties,anyOfbranches reached from the root, and each property'sskip_prompt_if)? Or is rejecting these other depths a deliberate tightening? If so, the doc comment, the description and the changelog entry should say that, not describe it as a crash fix.
4d3ef78 to
6cbf39e
Compare
Sankalp-Mittal
left a comment
There was a problem hiding this comment.
[AI Generated] Review by review-factory (Claude Opus 5.5 + Claude Sonnet 5.5 + Claude Opus 5.5, cross-verified). Only points the reviewers agreed on are posted.
No issues found.
…emplate
json.Unmarshal stores "properties": {"p": null} as a nil *Schema, which
LoadFS and the instance validators then dereference. LoadFS now rejects
null property schemas at any depth (nested properties, items, anyOf,
oneOf, skip_prompt_if) with an error naming the property.
Co-authored-by: Isaac <no-reply@databricks.com>
6cbf39e to
275e7c4
Compare
The walk also rejected nulls under nested properties, items and oneOf, which nothing reads, so templates that load today would have stopped loading. Check only what LoadFS and ValidateInstance dereference: the root properties, anyOf branches (recursively) and each top-level property's skip_prompt_if. Co-authored-by: Isaac <no-reply@databricks.com>
|
🤖 Answering the open question in the review at What remains is a judgment call, now in "Gaps and risks": a null in a root AI agent (opus5.5, isaac_claude) |
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.
No new issues found.
Changes
LoadFSin libs/jsonschema/schema.go now rejects a property whose schema is JSONnullright after unmarshaling, with an error naming the property.json.Unmarshalstores"p": nullas a nil*Schema. The check covers exactly the places where the loader and the template code dereference it: the rootproperties,anyOfbranches (recursively, asValidateInstanceevaluates them), and each top-level property'sskip_prompt_if(validated as an instance while prompting). A null under nestedproperties,itemsoroneOfis never read, so it is left alone and such templates keep loading as before."items": nulland"skip_prompt_if": nullstill mean "absent".bundle initeffect, in acceptance/bundle/templates-machinery/null-property-schema (from the test PR):"properties": {"p": null}:Error: failed to load schema: schema for property p is nullinstead of a panic."anyOf": [{"properties": {"q": null}}]withqin the config file:Error: failed to load schema: schema for property anyOf[0].q is nullinstead of a panic.Unit tests in schema_test.go cover each rejected place, including
skip_prompt_if, whose panic needs a TTY (prompting evaluates it against the values entered so far), and check that a null in the unread places still loads. Badness, the stack-trace filter and the LOG files are removed from the test.Why
This PR was created by analyzing coverage gaps. Coverage: http://go/cli/dashboard/coverage/file/libs/jsonschema/schema.go (LoadFS, lines 323-368).
A malformed template schema crashes
bundle initwith a stack trace and a "please report this issue" message, when a one-line error pointing at the property is all the template author needs. All production loaders (bundle initandbundle debug render-template-schema) go throughLoadFS, so one check there covers them.Test: #8167
Gaps and risks
anyOfbranch or a top-levelskip_prompt_ifis rejected at load even when that branch would not have been evaluated for the given config (for example a branch whose keys the config did not set). The same file panics as soon as it is evaluated, so the earlier failure is intended. Nulls in places nothing reads (nestedproperties,items,oneOf, a nested property'sskip_prompt_if) still load, so no template that is usable today stops loading.anyOfbranch or askip_prompt_ifis a latent crash that some configs never hit (for example when an earlieranyOfbranch matches first). Such a template loads on main and fails at load with this change. The alternative, checking lazily inside each validator, would spread the check over every validator; rejecting the malformed schema at load gives the template author one clear error instead of a crash that depends on the config.additionalPropertiesand$defsare untyped (any) in this package and never dereferenced as*Schema, so they are left out of the walk.skip_prompt_ifcase was not run end to end on a TTY; the unit test covers the load-time rejection.🤖 AI agent (opus5.5, isaac_claude)
This pull request and its description were written by Isaac.