Skip to content

Return an error instead of panicking on a null property schema in a template - #8168

Merged
denik merged 2 commits into
mainfrom
denik/fix-jsonschema-null-property
Nov 29, 2026
Merged

denik merged 2 commits into
mainfrom
denik/fix-jsonschema-null-property

Conversation

@denik

@denik denik commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Changes

LoadFS in libs/jsonschema/schema.go now rejects a property whose schema is JSON null right after unmarshaling, with an error naming the property. json.Unmarshal stores "p": null as a nil *Schema. The check covers exactly the places where the loader and the template code dereference it: the root properties, anyOf branches (recursively, as ValidateInstance evaluates them), and each top-level property's skip_prompt_if (validated as an instance while prompting). A null under nested properties, items or oneOf is never read, so it is left alone and such templates keep loading as before. "items": null and "skip_prompt_if": null still mean "absent".

bundle init effect, 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 null instead of a panic.
  • "anyOf": [{"properties": {"q": null}}] with q in the config file: Error: failed to load schema: schema for property anyOf[0].q is null instead 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 init with 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 init and bundle debug render-template-schema) go through LoadFS, so one check there covers them.

Test: #8167

Gaps and risks

  • A null in a root anyOf branch or a top-level skip_prompt_if is 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 (nested properties, items, oneOf, a nested property's skip_prompt_if) still load, so no template that is usable today stops loading.
  • Judgment call: validators dereference a property only when the config sets its key, so a null in a root anyOf branch or a skip_prompt_if is a latent crash that some configs never hit (for example when an earlier anyOf branch 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.
  • Schemas under additionalProperties and $defs are untyped (any) in this package and never dereferenced as *Schema, so they are left out of the walk.
  • The skip_prompt_if case was not run end to end on a TTY; the unit test covers the load-time rejection.
  • Risk: low (it turns a panic into an error at schema load).

🤖 AI agent (opus5.5, isaac_claude)

This pull request and its description were written by Isaac.

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Regression test report ✅

Commit: 1eff7db15 | Workflow run

Selected 1 changed tests (limit=20, 0 not selected)

2 tests: regression=2 unreleased=0 coverage=0 failing=0
test branch main (d164fcc) latest (v1.28.0)
TestAccept/bundle/templates-machinery/null-property-schema/DMS= ✅ ❌ ❌
TestAccept/bundle/templates-machinery/null-property-schema/DMS=true ✅ ❌ ❌
TestAccept/bundle/templates-machinery/null-property-schema/DMS=: branch ✅ | main (d164fcc) ❌ | latest (v1.28.0) ❌

main (d164fcc):

acceptance_test.go:1402: Diff:
        --- bundle/templates-machinery/null-property-schema/output.txt
        +++ /tmp/TestAcceptbundletemplates-machinerynull-property-schemaDMS=3194235091/002/output.txt
        @@ -2,9 +2,93 @@
         === top-level property whose schema is null
         
         >>> musterr [CLI] bundle init ./top --output-dir rendered
        -Error: failed to load schema: schema for property p is null
        +The Databricks CLI unexpectedly had a fatal error.
        +Please report this issue to Databricks in the form of a GitHub issue at:
        +https://github.com/databricks/cli
         
        +CLI Version: [CLI_VERSION]
        +
        +Panic Payload: runtime error: invalid memory address or nil pointer dereference
        +
        +Stack Trace:
        +goroutine 1 [running]:
        +runtime/debug.Stack()
        +	/opt/hostedtoolcache/go/[GO_VERSION]/x64/src/runtime/debug/stack.go:26 +0x5e
        +github.com/databricks/cli/cmd/root.execute.func1()
        +	/tmp/TestAccept1747681860/001/cmd/root/root.go:169 +0xd4
        +panic({0x361ba08?, 0x3ba8b40?})
        +	/opt/hostedtoolcache/go/[GO_VERSION]/x64/src/runtime/panic.go:859 +0x125
        +github.com/databricks/cli/libs/jsonschema.LoadFS({0x396e700?, 0x2b9af5eec5c0?}, {0x1c7e5fb?, 0x2b9af5afe420?})
        +	/tmp/TestAccept1747681860/001/libs/jsonschema/schema.go:344 +0x154
        +github.com/databricks/cli/libs/template.loadSchemaAndResolveTemplateDir({0x7ffeb473d03b, 0x5})
        +	/tmp/TestAccept1747681860/001/libs/template/reader.go:207 +0x53
        +github.com/databricks/cli/libs/template.(*localReader).LoadSchemaAndTemplateFS(0x7ffeb473d03b?, {0x0?, 0x0?})
        +	/tmp/TestAccept1747681860/001/libs/template/reader.go:194 +0x1d
        +github.com/databricks/cli/libs/template.(*defaultWriter).promptForInput(0x2b9af5f4a7c0, {0x3985f40, 0x2b9af5f667e0}, {0x3983358?, 0x2b9af5eec5a0?})
        +	/tmp/TestAccept1747681860/001/libs/template/writer.go:105 +0x3d
        +github.com/databricks/cli/libs/template.(*defaultWriter).Materialize(0x2b9af5f4a7c0, {0x3985f40, 0x2b9af5f667e0}, {0x3983358?, 0x2b9af5eec5a0?})
        +	/tmp/TestAccept1747681860/001/libs/template/writer.go:168 +0x30
        +github.com/databricks/cli/cmd/bundle.newInitCommand.func1(0x2b9af5f3c608, {0x2b9af5f372f0?, 0x4?, 0x1c31e56?})
        +	/tmp/TestAccept1747681860/001/cmd/bundle/init.go:92 +0x453
        +github.com/spf13/cobra.(*Command).execute(0x2b9af5f3c608, {0x2b9af5f37290, 0x3, 0x3})
        +	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.10.2/command.go:1015 +0xb3c
        +github.com/spf13/cobra.(*Command).ExecuteC(0x2b9af5d08c08)
        +	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.10.2/command.go:1148 +0x450
        +github.com/spf13/cobra.(*Command).ExecuteContextC(...)
        +	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.10.2/command.go:1080
        +github.com/databricks/cli/cmd/root.execute({0x3985f08, 0x3c1a560}, 0x2b9af5d08c08, {0x2b9af5aea610, 0x5, 0x5})
        +	/tmp/TestAccept1747681860/001/cmd/root/root.go:231 +0x413
        +github.com/databricks/cli/cmd/root.(*Tree).Execute(0x2b9af5e1f910, {0x3985f08, 0x3c1a560}, {0x2b9af5aea610, 0x5, 0x5})
        +	/tmp/TestAccept1747681860/001/cmd/root/tree.go:65 +0x57
        +main.main()
        +	/tmp/TestAccept1747681860/001/main.go:36 +0x125
        +
         === property whose schema is null in a root anyOf branch
         
         >>> musterr [CLI] bundle init ./any-of --config-file q.json --output-dir rendered
        -Error: failed to load schema: schema for property anyOf[0].q is null
        +The Databricks CLI unexpectedly had a fatal error.
        +Please report this issue to Databricks in the form of a GitHub issue at:
        +https://github.com/databricks/cli
        +
        +CLI Version: [CLI_VERSION]
        +
        +Panic Payload: runtime error: invalid memory address or nil pointer dereference
        +
        +Stack Trace:
        +goroutine 1 [running]:
        +runtime/debug.Stack()
        +	/opt/hostedtoolcache/go/[GO_VERSION]/x64/src/runtime/debug/stack.go:26 +0x5e
        +github.com/databricks/cli/cmd/root.execute.func1()
        +	/tmp/TestAccept1747681860/001/cmd/root/root.go:169 +0xd4
        +panic({0x361ba08?, 0x3ba8b40?})
        +	/opt/hostedtoolcache/go/[GO_VERSION]/x64/src/runtime/panic.go:859 +0x125
        +github.com/databricks/cli/libs/jsonschema.(*Schema).validateEnum(0x12e6ce244800, 0x523185?)
        +	/tmp/TestAccept1747681860/001/libs/jsonschema/instance.go:106 +0xbb
        +github.com/databricks/cli/libs/jsonschema.(*Schema).ValidateInstance(0x359bcb0?, 0x12e6ce24c480)
        +	/tmp/TestAccept1747681860/001/libs/jsonschema/instance.go:53 +0x12a
        +github.com/databricks/cli/libs/jsonschema.(*Schema).validateAnyOf(0x12e6ce244200?, 0x12e6ce24c480)
        +	/tmp/TestAccept1747681860/001/libs/jsonschema/instance.go:157 +0x1cc
        +github.com/databricks/cli/libs/jsonschema.(*Schema).ValidateInstance(0x3469138?, 0x12e6ce24c480)
        +	/tmp/TestAccept1747681860/001/libs/jsonschema/instance.go:53 +0x12a
        +github.com/databricks/cli/libs/jsonschema.(*Schema).LoadInstance(0x12e6ce244200, {0x7fff9be7b03a, 0x6})
        +	/tmp/TestAccept1747681860/001/libs/jsonschema/instance.go:37 +0x34a
        +github.com/databricks/cli/libs/template.(*config).assignValuesFromFile(0x12e6ce16b260, {0x7fff9be7b03a, 0x6})
        +	/tmp/TestAccept1747681860/001/libs/template/config.go:86 +0x74
        +github.com/databricks/cli/libs/template.(*defaultWriter).promptForInput(0x12e6ce230580, {0x3985f40, 0x12e6ce219ec0}, {0x3983358?, 0x12e6ce1cedb0?})
        +	/tmp/TestAccept1747681860/001/libs/template/writer.go:117 +0xae
        +github.com/databricks/cli/libs/template.(*defaultWriter).Materialize(0x12e6ce230580, {0x3985f40, 0x12e6ce219ec0}, {0x3983358?, 0x12e6ce1cedb0?})
        +	/tmp/TestAccept1747681860/001/libs/template/writer.go:168 +0x30
        +github.com/databricks/cli/cmd/bundle.newInitCommand.func1(0x12e6ce21e608, {0x12e6ce0cfc20?, 0x4?, 0x1c31e56?})
        +	/tmp/TestAccept1747681860/001/cmd/bundle/init.go:92 +0x453
        +github.com/spf13/cobra.(*Command).execute(0x12e6ce21e608, {0x12e6ce0cfbd0, 0x5, 0x5})
        +	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.10.2/command.go:1015 +0xb3c
        +github.com/spf13/cobra.(*Command).ExecuteC(0x12e6cdf7ac08)
        +	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.10.2/command.go:1148 +0x450
        +github.com/spf13/cobra.(*Command).ExecuteContextC(...)
        +	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.10.2/command.go:1080
        +github.com/databricks/cli/cmd/root.execute({0x3985f08, 0x3c1a560}, 0x12e6cdf7ac08, {0x12e6cddd6610, 0x7, 0x7})
        +	/tmp/TestAccept1747681860/001/cmd/root/root.go:231 +0x413
        +github.com/databricks/cli/cmd/root.(*Tree).Execute(0x12e6ce103910, {0x3985f08, 0x3c1a560}, {0x12e6cddd6610, 0x7, 0x7})
        +	/tmp/TestAccept1747681860/001/cmd/root/tree.go:65 +0x57
        +main.main()
        +	/tmp/TestAccept1747681860/001/main.go:36 +0x125

latest (v1.28.0):

acceptance_test.go:1402: Diff:
        --- bundle/templates-machinery/null-property-schema/output.txt
        +++ /tmp/TestAcceptbundletemplates-machinerynull-property-schemaDMS=2206846227/002/output.txt
        @@ -2,9 +2,93 @@
         === top-level property whose schema is null
         
         >>> musterr [CLI] bundle init ./top --output-dir rendered
        -Error: failed to load schema: schema for property p is null
        +The Databricks CLI unexpectedly had a fatal error.
        +Please report this issue to Databricks in the form of a GitHub issue at:
        +https://github.com/databricks/cli
         
        +CLI Version: [CLI_VERSION]
        +
        +Panic Payload: runtime error: invalid memory address or nil pointer dereference
        +
        +Stack Trace:
        +goroutine 1 [running]:
        +runtime/debug.Stack()
        +	runtime/debug/stack.go:26 +0x5e
        +github.com/databricks/cli/cmd/root.execute.func1()
        +	github.com/databricks/cli/cmd/root/root.go:167 +0xd4
        +panic({0x352bad0?, 0x3aa09c0?})
        +	runtime/panic.go:859 +0x125
        +github.com/databricks/cli/libs/jsonschema.LoadFS({0x386e308?, 0x20a0f9dac280?}, {0x1c0e8a9?, 0x20a0f9da03c0?})
        +	github.com/databricks/cli/libs/jsonschema/schema.go:344 +0x154
        +github.com/databricks/cli/libs/template.loadSchemaAndResolveTemplateDir({0x7ffe3417cfdb, 0x5})
        +	github.com/databricks/cli/libs/template/reader.go:207 +0x53
        +github.com/databricks/cli/libs/template.(*localReader).LoadSchemaAndTemplateFS(0x7ffe3417cfdb?, {0x0?, 0x0?})
        +	github.com/databricks/cli/libs/template/reader.go:194 +0x1d
        +github.com/databricks/cli/libs/template.(*defaultWriter).promptForInput(0x20a0f9f740c0, {0x3885670, 0x20a0fa18ef30}, {0x3882cf8?, 0x20a0f9dac260?})
        +	github.com/databricks/cli/libs/template/writer.go:105 +0x3d
        +github.com/databricks/cli/libs/template.(*defaultWriter).Materialize(0x20a0f9f740c0, {0x3885670, 0x20a0fa18ef30}, {0x3882cf8?, 0x20a0f9dac260?})
        +	github.com/databricks/cli/libs/template/writer.go:168 +0x30
        +github.com/databricks/cli/cmd/bundle.newInitCommand.func1(0x20a0fa166308, {0x20a0fa10da40?, 0x4?, 0x1bc2e36?})
        +	github.com/databricks/cli/cmd/bundle/init.go:92 +0x453
        +github.com/spf13/cobra.(*Command).execute(0x20a0fa166308, {0x20a0fa10d9e0, 0x3, 0x3})
        +	github.com/spf13/cobra@v1.10.2/command.go:1015 +0xb3c
        +github.com/spf13/cobra.(*Command).ExecuteC(0x20a0f9ee4c08)
        +	github.com/spf13/cobra@v1.10.2/command.go:1148 +0x450
        +github.com/spf13/cobra.(*Command).ExecuteContextC(...)
        +	github.com/spf13/cobra@v1.10.2/command.go:1080
        +github.com/databricks/cli/cmd/root.execute({0x3885638, 0x3b11cc0}, 0x20a0f9ee4c08, {0x20a0f9e265b0, 0x5, 0x5})
        +	github.com/databricks/cli/cmd/root/root.go:227 +0x3b6
        +github.com/databricks/cli/cmd/root.(*Tree).Execute(0x20a0fa0653c0, {0x3885638, 0x3b11cc0}, {0x20a0f9e265b0, 0x5, 0x5})
        +	github.com/databricks/cli/cmd/root/tree.go:65 +0x57
        +main.main()
        +	github.com/databricks/cli/main.go:36 +0x125
        +
         === property whose schema is null in a root anyOf branch
         
         >>> musterr [CLI] bundle init ./any-of --config-file q.json --output-dir rendered
        -Error: failed to load schema: schema for property anyOf[0].q is null
        +The Databricks CLI unexpectedly had a fatal error.
        +Please report this issue to Databricks in the form of a GitHub issue at:
        +https://github.com/databricks/cli
        +
        +CLI Version: [CLI_VERSION]
        +
        +Panic Payload: runtime error: invalid memory address or nil pointer dereference
        +
        +Stack Trace:
        +goroutine 1 [running]:
        +runtime/debug.Stack()
        +	runtime/debug/stack.go:26 +0x5e
        +github.com/databricks/cli/cmd/root.execute.func1()
        +	github.com/databricks/cli/cmd/root/root.go:167 +0xd4
        +panic({0x352bad0?, 0x3aa09c0?})
        +	runtime/panic.go:859 +0x125
        +github.com/databricks/cli/libs/jsonschema.(*Schema).validateEnum(0x23701a84c200, 0x520c85?)
        +	github.com/databricks/cli/libs/jsonschema/instance.go:106 +0xbb
        +github.com/databricks/cli/libs/jsonschema.(*Schema).ValidateInstance(0x34aeba8?, 0x23701a83cbd0)
        +	github.com/databricks/cli/libs/jsonschema/instance.go:53 +0x12a
        +github.com/databricks/cli/libs/jsonschema.(*Schema).validateAnyOf(0x23701a3b9a00?, 0x23701a83cbd0)
        +	github.com/databricks/cli/libs/jsonschema/instance.go:157 +0x1cc
        +github.com/databricks/cli/libs/jsonschema.(*Schema).ValidateInstance(0x3382ff8?, 0x23701a83cbd0)
        +	github.com/databricks/cli/libs/jsonschema/instance.go:53 +0x12a
        +github.com/databricks/cli/libs/jsonschema.(*Schema).LoadInstance(0x23701a3b9a00, {0x7ffffde3bfda, 0x6})
        +	github.com/databricks/cli/libs/jsonschema/instance.go:37 +0x34a
        +github.com/databricks/cli/libs/template.(*config).assignValuesFromFile(0x23701a774f60, {0x7ffffde3bfda, 0x6})
        +	github.com/databricks/cli/libs/template/config.go:86 +0x74
        +github.com/databricks/cli/libs/template.(*defaultWriter).promptForInput(0x23701a790e40, {0x3885670, 0x23701a83c720}, {0x3882cf8?, 0x23701a81c800?})
        +	github.com/databricks/cli/libs/template/writer.go:117 +0xae
        +github.com/databricks/cli/libs/template.(*defaultWriter).Materialize(0x23701a790e40, {0x3885670, 0x23701a83c720}, {0x3882cf8?, 0x23701a81c800?})
        +	github.com/databricks/cli/libs/template/writer.go:168 +0x30
        +github.com/databricks/cli/cmd/bundle.newInitCommand.func1(0x23701a81a308, {0x23701a6efa40?, 0x4?, 0x1bc2e36?})
        +	github.com/databricks/cli/cmd/bundle/init.go:92 +0x453
        +github.com/spf13/cobra.(*Command).execute(0x23701a81a308, {0x23701a6ef9f0, 0x5, 0x5})
        +	github.com/spf13/cobra@v1.10.2/command.go:1015 +0xb3c
        +github.com/spf13/cobra.(*Command).ExecuteC(0x23701a576c08)
        +	github.com/spf13/cobra@v1.10.2/command.go:1148 +0x450
        +github.com/spf13/cobra.(*Command).ExecuteContextC(...)
        +	github.com/spf13/cobra@v1.10.2/command.go:1080
        +github.com/databricks/cli/cmd/root.execute({0x3885638, 0x3b11cc0}, 0x23701a576c08, {0x23701a40a610, 0x7, 0x7})
        +	github.com/databricks/cli/cmd/root/root.go:227 +0x3b6
        +github.com/databricks/cli/cmd/root.(*Tree).Execute(0x23701a7213f0, {0x3885638, 0x3b11cc0}, {0x23701a40a610, 0x7, 0x7})
        +	github.com/databricks/cli/cmd/root/tree.go:65 +0x57
        +main.main()
        +	github.com/databricks/cli/main.go:36 +0x125
TestAccept/bundle/templates-machinery/null-property-schema/DMS=true: branch ✅ | main (d164fcc) ❌ | latest (v1.28.0) ❌

main (d164fcc):

acceptance_test.go:1402: Diff:
        --- bundle/templates-machinery/null-property-schema/output.txt
        +++ /tmp/TestAcceptbundletemplates-machinerynull-property-schemaDMS=t70311494/002/output.txt
        @@ -2,9 +2,93 @@
         === top-level property whose schema is null
         
         >>> musterr [CLI] bundle init ./top --output-dir rendered
        -Error: failed to load schema: schema for property p is null
        +The Databricks CLI unexpectedly had a fatal error.
        +Please report this issue to Databricks in the form of a GitHub issue at:
        +https://github.com/databricks/cli
         
        +CLI Version: [CLI_VERSION]
        +
        +Panic Payload: runtime error: invalid memory address or nil pointer dereference
        +
        +Stack Trace:
        +goroutine 1 [running]:
        +runtime/debug.Stack()
        +	/opt/hostedtoolcache/go/[GO_VERSION]/x64/src/runtime/debug/stack.go:26 +0x5e
        +github.com/databricks/cli/cmd/root.execute.func1()
        +	/tmp/TestAccept1747681860/001/cmd/root/root.go:169 +0xd4
        +panic({0x361ba08?, 0x3ba8b40?})
        +	/opt/hostedtoolcache/go/[GO_VERSION]/x64/src/runtime/panic.go:859 +0x125
        +github.com/databricks/cli/libs/jsonschema.LoadFS({0x396e700?, 0x3c35b4812300?}, {0x1c7e5fb?, 0x1?})
        +	/tmp/TestAccept1747681860/001/libs/jsonschema/schema.go:344 +0x154
        +github.com/databricks/cli/libs/template.loadSchemaAndResolveTemplateDir({0x7fffb7e79039, 0x5})
        +	/tmp/TestAccept1747681860/001/libs/template/reader.go:207 +0x53
        +github.com/databricks/cli/libs/template.(*localReader).LoadSchemaAndTemplateFS(0x7fffb7e79039?, {0x0?, 0x0?})
        +	/tmp/TestAccept1747681860/001/libs/template/reader.go:194 +0x1d
        +github.com/databricks/cli/libs/template.(*defaultWriter).promptForInput(0x3c35b48521c0, {0x3985f40, 0x3c35b48767b0}, {0x3983358?, 0x3c35b48122e0?})
        +	/tmp/TestAccept1747681860/001/libs/template/writer.go:105 +0x3d
        +github.com/databricks/cli/libs/template.(*defaultWriter).Materialize(0x3c35b48521c0, {0x3985f40, 0x3c35b48767b0}, {0x3983358?, 0x3c35b48122e0?})
        +	/tmp/TestAccept1747681860/001/libs/template/writer.go:168 +0x30
        +github.com/databricks/cli/cmd/bundle.newInitCommand.func1(0x3c35b4c12608, {0x3c35b4c0d2f0?, 0x4?, 0x1c31e56?})
        +	/tmp/TestAccept1747681860/001/cmd/bundle/init.go:92 +0x453
        +github.com/spf13/cobra.(*Command).execute(0x3c35b4c12608, {0x3c35b4c0d290, 0x3, 0x3})
        +	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.10.2/command.go:1015 +0xb3c
        +github.com/spf13/cobra.(*Command).ExecuteC(0x3c35b4972c08)
        +	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.10.2/command.go:1148 +0x450
        +github.com/spf13/cobra.(*Command).ExecuteContextC(...)
        +	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.10.2/command.go:1080
        +github.com/databricks/cli/cmd/root.execute({0x3985f08, 0x3c1a560}, 0x3c35b4972c08, {0x3c35b4880610, 0x5, 0x5})
        +	/tmp/TestAccept1747681860/001/cmd/root/root.go:231 +0x413
        +github.com/databricks/cli/cmd/root.(*Tree).Execute(0x3c35b4af98e0, {0x3985f08, 0x3c1a560}, {0x3c35b4880610, 0x5, 0x5})
        +	/tmp/TestAccept1747681860/001/cmd/root/tree.go:65 +0x57
        +main.main()
        +	/tmp/TestAccept1747681860/001/main.go:36 +0x125
        +
         === property whose schema is null in a root anyOf branch
         
         >>> musterr [CLI] bundle init ./any-of --config-file q.json --output-dir rendered
        -Error: failed to load schema: schema for property anyOf[0].q is null
        +The Databricks CLI unexpectedly had a fatal error.
        +Please report this issue to Databricks in the form of a GitHub issue at:
        +https://github.com/databricks/cli
        +
        +CLI Version: [CLI_VERSION]
        +
        +Panic Payload: runtime error: invalid memory address or nil pointer dereference
        +
        +Stack Trace:
        +goroutine 1 [running]:
        +runtime/debug.Stack()
        +	/opt/hostedtoolcache/go/[GO_VERSION]/x64/src/runtime/debug/stack.go:26 +0x5e
        +github.com/databricks/cli/cmd/root.execute.func1()
        +	/tmp/TestAccept1747681860/001/cmd/root/root.go:169 +0xd4
        +panic({0x361ba08?, 0x3ba8b40?})
        +	/opt/hostedtoolcache/go/[GO_VERSION]/x64/src/runtime/panic.go:859 +0x125
        +github.com/databricks/cli/libs/jsonschema.(*Schema).validateEnum(0x288e2a63c600, 0x523185?)
        +	/tmp/TestAccept1747681860/001/libs/jsonschema/instance.go:106 +0xbb
        +github.com/databricks/cli/libs/jsonschema.(*Schema).ValidateInstance(0x359bcb0?, 0x288e2a63e480)
        +	/tmp/TestAccept1747681860/001/libs/jsonschema/instance.go:53 +0x12a
        +github.com/databricks/cli/libs/jsonschema.(*Schema).validateAnyOf(0x288e2a63c000?, 0x288e2a63e480)
        +	/tmp/TestAccept1747681860/001/libs/jsonschema/instance.go:157 +0x1cc
        +github.com/databricks/cli/libs/jsonschema.(*Schema).ValidateInstance(0x3469138?, 0x288e2a63e480)
        +	/tmp/TestAccept1747681860/001/libs/jsonschema/instance.go:53 +0x12a
        +github.com/databricks/cli/libs/jsonschema.(*Schema).LoadInstance(0x288e2a63c000, {0x7ffe23060038, 0x6})
        +	/tmp/TestAccept1747681860/001/libs/jsonschema/instance.go:37 +0x34a
        +github.com/databricks/cli/libs/template.(*config).assignValuesFromFile(0x288e2a565240, {0x7ffe23060038, 0x6})
        +	/tmp/TestAccept1747681860/001/libs/template/config.go:86 +0x74
        +github.com/databricks/cli/libs/template.(*defaultWriter).promptForInput(0x288e2a624580, {0x3985f40, 0x288e2a60dec0}, {0x3983358?, 0x288e2a5c2d80?})
        +	/tmp/TestAccept1747681860/001/libs/template/writer.go:117 +0xae
        +github.com/databricks/cli/libs/template.(*defaultWriter).Materialize(0x288e2a624580, {0x3985f40, 0x288e2a60dec0}, {0x3983358?, 0x288e2a5c2d80?})
        +	/tmp/TestAccept1747681860/001/libs/template/writer.go:168 +0x30
        +github.com/databricks/cli/cmd/bundle.newInitCommand.func1(0x288e2a612608, {0x288e2a4c1c20?, 0x4?, 0x1c31e56?})
        +	/tmp/TestAccept1747681860/001/cmd/bundle/init.go:92 +0x453
        +github.com/spf13/cobra.(*Command).execute(0x288e2a612608, {0x288e2a4c1bd0, 0x5, 0x5})
        +	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.10.2/command.go:1015 +0xb3c
        +github.com/spf13/cobra.(*Command).ExecuteC(0x288e2a372c08)
        +	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.10.2/command.go:1148 +0x450
        +github.com/spf13/cobra.(*Command).ExecuteContextC(...)
        +	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.10.2/command.go:1080
        +github.com/databricks/cli/cmd/root.execute({0x3985f08, 0x3c1a560}, 0x288e2a372c08, {0x288e2a2aa590, 0x7, 0x7})
        +	/tmp/TestAccept1747681860/001/cmd/root/root.go:231 +0x413
        +github.com/databricks/cli/cmd/root.(*Tree).Execute(0x288e2a4f98e0, {0x3985f08, 0x3c1a560}, {0x288e2a2aa590, 0x7, 0x7})
        +	/tmp/TestAccept1747681860/001/cmd/root/tree.go:65 +0x57
        +main.main()
        +	/tmp/TestAccept1747681860/001/main.go:36 +0x125
        
FAIL

latest (v1.28.0):

acceptance_test.go:1402: Diff:
        --- bundle/templates-machinery/null-property-schema/output.txt
        +++ /tmp/TestAcceptbundletemplates-machinerynull-property-schemaDMS=t595013157/002/output.txt
        @@ -2,9 +2,93 @@
         === top-level property whose schema is null
         
         >>> musterr [CLI] bundle init ./top --output-dir rendered
        -Error: failed to load schema: schema for property p is null
        +The Databricks CLI unexpectedly had a fatal error.
        +Please report this issue to Databricks in the form of a GitHub issue at:
        +https://github.com/databricks/cli
         
        +CLI Version: [CLI_VERSION]
        +
        +Panic Payload: runtime error: invalid memory address or nil pointer dereference
        +
        +Stack Trace:
        +goroutine 1 [running]:
        +runtime/debug.Stack()
        +	runtime/debug/stack.go:26 +0x5e
        +github.com/databricks/cli/cmd/root.execute.func1()
        +	github.com/databricks/cli/cmd/root/root.go:167 +0xd4
        +panic({0x352bad0?, 0x3aa09c0?})
        +	runtime/panic.go:859 +0x125
        +github.com/databricks/cli/libs/jsonschema.LoadFS({0x386e308?, 0x29b1d96fd410?}, {0x1c0e8a9?, 0xa?})
        +	github.com/databricks/cli/libs/jsonschema/schema.go:344 +0x154
        +github.com/databricks/cli/libs/template.loadSchemaAndResolveTemplateDir({0x7ffea52d9fd3, 0x5})
        +	github.com/databricks/cli/libs/template/reader.go:207 +0x53
        +github.com/databricks/cli/libs/template.(*localReader).LoadSchemaAndTemplateFS(0x7ffea52d9fd3?, {0x0?, 0x0?})
        +	github.com/databricks/cli/libs/template/reader.go:194 +0x1d
        +github.com/databricks/cli/libs/template.(*defaultWriter).promptForInput(0x29b1d9798600, {0x3885670, 0x29b1d979f410}, {0x3882cf8?, 0x29b1d96fd3f0?})
        +	github.com/databricks/cli/libs/template/writer.go:105 +0x3d
        +github.com/databricks/cli/libs/template.(*defaultWriter).Materialize(0x29b1d9798600, {0x3885670, 0x29b1d979f410}, {0x3882cf8?, 0x29b1d96fd3f0?})
        +	github.com/databricks/cli/libs/template/writer.go:168 +0x30
        +github.com/databricks/cli/cmd/bundle.newInitCommand.func1(0x29b1d9778308, {0x29b1d979e030?, 0x4?, 0x1bc2e36?})
        +	github.com/databricks/cli/cmd/bundle/init.go:92 +0x453
        +github.com/spf13/cobra.(*Command).execute(0x29b1d9778308, {0x29b1d96ffec0, 0x3, 0x3})
        +	github.com/spf13/cobra@v1.10.2/command.go:1015 +0xb3c
        +github.com/spf13/cobra.(*Command).ExecuteC(0x29b1d94e2c08)
        +	github.com/spf13/cobra@v1.10.2/command.go:1148 +0x450
        +github.com/spf13/cobra.(*Command).ExecuteContextC(...)
        +	github.com/spf13/cobra@v1.10.2/command.go:1080
        +github.com/databricks/cli/cmd/root.execute({0x3885638, 0x3b11cc0}, 0x29b1d94e2c08, {0x29b1d93581f0, 0x5, 0x5})
        +	github.com/databricks/cli/cmd/root/root.go:227 +0x3b6
        +github.com/databricks/cli/cmd/root.(*Tree).Execute(0x29b1d962bd30, {0x3885638, 0x3b11cc0}, {0x29b1d93581f0, 0x5, 0x5})
        +	github.com/databricks/cli/cmd/root/tree.go:65 +0x57
        +main.main()
        +	github.com/databricks/cli/main.go:36 +0x125
        +
         === property whose schema is null in a root anyOf branch
         
         >>> musterr [CLI] bundle init ./any-of --config-file q.json --output-dir rendered
        -Error: failed to load schema: schema for property anyOf[0].q is null
        +The Databricks CLI unexpectedly had a fatal error.
        +Please report this issue to Databricks in the form of a GitHub issue at:
        +https://github.com/databricks/cli
        +
        +CLI Version: [CLI_VERSION]
        +
        +Panic Payload: runtime error: invalid memory address or nil pointer dereference
        +
        +Stack Trace:
        +goroutine 1 [running]:
        +runtime/debug.Stack()
        +	runtime/debug/stack.go:26 +0x5e
        +github.com/databricks/cli/cmd/root.execute.func1()
        +	github.com/databricks/cli/cmd/root/root.go:167 +0xd4
        +panic({0x352bad0?, 0x3aa09c0?})
        +	runtime/panic.go:859 +0x125
        +github.com/databricks/cli/libs/jsonschema.(*Schema).validateEnum(0x2a535b1f5200, 0x520c85?)
        +	github.com/databricks/cli/libs/jsonschema/instance.go:106 +0xbb
        +github.com/databricks/cli/libs/jsonschema.(*Schema).ValidateInstance(0x34aeba8?, 0x2a535b692120)
        +	github.com/databricks/cli/libs/jsonschema/instance.go:53 +0x12a
        +github.com/databricks/cli/libs/jsonschema.(*Schema).validateAnyOf(0x2a535b1f4c00?, 0x2a535b692120)
        +	github.com/databricks/cli/libs/jsonschema/instance.go:157 +0x1cc
        +github.com/databricks/cli/libs/jsonschema.(*Schema).ValidateInstance(0x3382ff8?, 0x2a535b692120)
        +	github.com/databricks/cli/libs/jsonschema/instance.go:53 +0x12a
        +github.com/databricks/cli/libs/jsonschema.(*Schema).LoadInstance(0x2a535b1f4c00, {0x7ffd44076fd2, 0x6})
        +	github.com/databricks/cli/libs/jsonschema/instance.go:37 +0x34a
        +github.com/databricks/cli/libs/template.(*config).assignValuesFromFile(0x2a535b29c6c0, {0x7ffd44076fd2, 0x6})
        +	github.com/databricks/cli/libs/template/config.go:86 +0x74
        +github.com/databricks/cli/libs/template.(*defaultWriter).promptForInput(0x2a535b2ce7c0, {0x3885670, 0x2a535b2c5b60}, {0x3882cf8?, 0x2a535b2668a0?})
        +	github.com/databricks/cli/libs/template/writer.go:117 +0xae
        +github.com/databricks/cli/libs/template.(*defaultWriter).Materialize(0x2a535b2ce7c0, {0x3885670, 0x2a535b2c5b60}, {0x3882cf8?, 0x2a535b2668a0?})
        +	github.com/databricks/cli/libs/template/writer.go:168 +0x30
        +github.com/databricks/cli/cmd/bundle.newInitCommand.func1(0x2a535b2d8008, {0x2a535b2ee0a0?, 0x4?, 0x1bc2e36?})
        +	github.com/databricks/cli/cmd/bundle/init.go:92 +0x453
        +github.com/spf13/cobra.(*Command).execute(0x2a535b2d8008, {0x2a535b2ee050, 0x5, 0x5})
        +	github.com/spf13/cobra@v1.10.2/command.go:1015 +0xb3c
        +github.com/spf13/cobra.(*Command).ExecuteC(0x2a535b3e4c08)
        +	github.com/spf13/cobra@v1.10.2/command.go:1148 +0x450
        +github.com/spf13/cobra.(*Command).ExecuteContextC(...)
        +	github.com/spf13/cobra@v1.10.2/command.go:1080
        +github.com/databricks/cli/cmd/root.execute({0x3885638, 0x3b11cc0}, 0x2a535b3e4c08, {0x2a535b31e590, 0x7, 0x7})
        +	github.com/databricks/cli/cmd/root/root.go:227 +0x3b6
        +github.com/databricks/cli/cmd/root.(*Tree).Execute(0x2a535b5673c0, {0x3885638, 0x3b11cc0}, {0x2a535b31e590, 0x7, 0x7})
        +	github.com/databricks/cli/cmd/root/tree.go:65 +0x57
        +main.main()
        +	github.com/databricks/cli/main.go:36 +0x125
        
FAIL

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: 1eff7db

Run: 46218313554

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 173 18 3:48
💚​ aws-windows-latest-4core-16gb 1 173 18 1:20
💚​ azure linux-2core-8gb 1 172 18 3:49
💚​ azure-windows-latest-4core-16gb 1 172 18 1:30
💚​ gcp linux-2core-8gb 1 173 18 3:36
💚​ gcp-windows-latest-4core-16gb 1 173 18 1:16
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 3 slowest tests (at least 2 minutes):
duration env testname
3:37 azure linux-2core-8gb TestAccept
3:36 aws linux-2core-8gb TestAccept
3:31 gcp linux-2core-8gb TestAccept

@denik
denik force-pushed the denik/fix-jsonschema-null-property branch from 27d86da to 4d3ef78 Compare November 29, 2026 00:44
@denik
denik marked this pull request as ready for review November 29, 2026 01:03
@denik
denik requested review from a team as code owners November 29, 2026 01:03
@denik
denik requested review from Sankalp-Mittal and andrewnester and removed request for a team November 29, 2026 01:03

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. [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 no oneOf validator, and nothing in instance.go or libs/template/config.go reads Items. Every validator also only loops over s.Properties of the schema it is called on, never over a property's own properties. So {"oneOf": [{"properties": {"p": null}}]} or a nested "properties": {"p": null} under a string property works with bundle init on base, and with this change it fails with failed to load schema. Should the walk stop at the paths that are actually dereferenced (root properties, anyOf branches reached from the root, and each property's skip_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.

@denik
denik force-pushed the denik/fix-jsonschema-null-property branch from 4d3ef78 to 6cbf39e Compare November 29, 2026 01:12

@Sankalp-Mittal Sankalp-Mittal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Base automatically changed from denik/acc-jsonschema-null-property to main November 29, 2026 02:21
@denik denik closed this in #8167 Nov 29, 2026
@denik denik reopened this Nov 29, 2026
…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>
@denik
denik force-pushed the denik/fix-jsonschema-null-property branch from 6cbf39e to 275e7c4 Compare November 29, 2026 02:34
@github-actions github-actions Bot added the DABs DABs related issues label Nov 29, 2026
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>
@denik

denik commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Answering the open question in the review at 4d3ef78: you're right, rejecting the other depths was not deliberate. Fixed in 1eff7db: the check now covers only what is dereferenced: the root properties, anyOf branches (recursively, as ValidateInstance evaluates them) and each top-level property's skip_prompt_if. A null under nested properties, items or oneOf (or a nested property's skip_prompt_if) is left alone and loads as on main; TestSchemaLoadFSAcceptsNullPropertySchemaInUnreadSchemas covers those cases. The doc comment and the description now say this.

What remains is a judgment call, now in "Gaps and risks": a null in a root anyOf branch or a skip_prompt_if is dereferenced only when the config sets that key, so some configs never hit it, and such a template now fails at load. I kept the load-time check because the schema is malformed, and the crash otherwise depends on the config.

AI agent (opus5.5, isaac_claude)

@denik
denik requested a review from andrewnester November 29, 2026 02:59

@Sankalp-Mittal Sankalp-Mittal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

@denik
denik added this pull request to the merge queue Nov 29, 2026
Merged via the queue into main with commit 7377a87 Nov 29, 2026
28 checks passed
@denik
denik deleted the denik/fix-jsonschema-null-property branch November 29, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DABs DABs related issues factory-generated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants