Skip to content

fix: std.manifestIni requires a sections field, matching official Jsonnet (#799)#886

Open
He-Pin wants to merge 1 commit into
databricks:masterfrom
He-Pin:fix/manifestIni-official-799
Open

fix: std.manifestIni requires a sections field, matching official Jsonnet (#799)#886
He-Pin wants to merge 1 commit into
databricks:masterfrom
He-Pin:fix/manifestIni-official-799

Conversation

@He-Pin
Copy link
Copy Markdown
Contributor

@He-Pin He-Pin commented May 31, 2026

Motivation

sjsonnet's std.manifestIni treated sections as optional:

std.manifestIni({ main: { a: "1" } })   // was: "a = 1\n"

Official Jsonnet 0.22.0 accesses ini.sections directly in std.jsonnet, so the same input errors with field does not exist: sections. Per the maintainer decision on #799 ("for manifestIni, I would follow the official approach"), this aligns sjsonnet with official strictness.

Modification

  • In the manifestIni builtin (ManifestModule), require the sections field — error Field does not exist: sections (sjsonnet's standard field-missing wording) when absent, instead of folding to an empty section list. main stays optional, matching the upstream std.objectHas(ini, 'main') check.
  • Regression tests:
    • manifestini_sections_required.jsonnetmain+sections, sections-only, and empty sections all work.
    • error.manifestini_requires_sections.jsonnet — missing sections errors.

Result

$ sjsonnet -e 'std.manifestIni({main: {a: "1"}})'
sjsonnet.Error: [std.manifestIni] Field does not exist: sections

All existing manifestIni tests already supply sections (the test suite uses the proper {main, sections} schema), so they are unaffected. Full JVM (Scala 3) test suite green.

Note: this PR addresses only the manifestIni half of #799. The manifestToml formatting differences (leading blank lines / nested-table indentation) are left for a separate discussion, as the desired behavior there was still open.

Addresses #799 (manifestIni).

…sonnet (databricks#799)

Motivation:
sjsonnet's std.manifestIni treated `sections` as optional: `std.manifestIni({main: {a: "1"}})`
returned "a = 1\n". Official Jsonnet 0.22.0 accesses `ini.sections` directly in std.jsonnet, so
the same input errors with `field does not exist: sections`. Per the maintainer decision on databricks#799,
follow the official approach.

Modification:
- In the manifestIni builtin (ManifestModule), require the `sections` field: error
  "Field does not exist: sections" (sjsonnet's standard field-missing wording) when absent,
  instead of folding to an empty section list. `main` stays optional, matching the upstream
  `std.objectHas(ini, 'main')` check.
- Add regression tests: manifestini_sections_required (main+sections, sections-only, empty
  sections all work) and error.manifestini_requires_sections (missing sections errors).

Result:
`std.manifestIni({main: {a: "1"}})` now errors `[std.manifestIni] Field does not exist: sections`.
All existing manifestIni tests already supply `sections`, so they are unaffected; full JVM test
suite green.

References: databricks#799
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant