Skip to content

[deckhouse-cli] Preserve object-level default map#374

Merged
ldmonster merged 1 commit into
mainfrom
fix/object-default-map-overlay
May 28, 2026
Merged

[deckhouse-cli] Preserve object-level default map#374
ldmonster merged 1 commit into
mainfrom
fix/object-default-map-overlay

Conversation

@Glitchy-Sheep
Copy link
Copy Markdown
Contributor

Problem

Object schemas with both properties and a default: {...} map silently dropped the default. synthesizeValue short-circuited on isObject(s) and returned the walk output, so rule 5 (default) never fired for object nodes.

Fix

In the object branch, overlay a map-typed s.Default on top of the walked properties via deepMergeOverride. Same precedence as x-example: walked properties form the baseline, the default wins on conflicts, nested unset fields keep their synthesized fallbacks.

Before / After

Schema:

type: object
properties:
  name: { type: string }
  port: { type: integer }
default:
  name: "override"
  extra: "kept"

Before:

name: "aB3xK9pQ"   # synthesized, default ignored
port: 123

After:

name: "override"   # from default
port: 123          # from walk
extra: "kept"      # from default

- `synthesizeValue` overlays a map-typed `s.Default` on top of the walked properties via `deepMergeOverride`, mirroring the precedence used for `x-example`.
- Object schemas that declared both `properties` and a `default` map no longer drop the default - author-supplied values win on conflicts, unset fields fall back to the synthesized walk.
- Package doc updated: rule 4 mentions the default-map overlay, rule 5 is scoped to non-object schemas.

Signed-off-by: Roman Berezkin <roman.berezkin@flant.com>
@Glitchy-Sheep Glitchy-Sheep self-assigned this May 28, 2026
@Glitchy-Sheep Glitchy-Sheep requested a review from ldmonster as a code owner May 28, 2026 14:46
@Glitchy-Sheep Glitchy-Sheep changed the title Preserve object-level default map when walking properties [deckhouse-cli] Preserve object-level default map May 28, 2026
@ldmonster ldmonster merged commit 49bca6b into main May 28, 2026
9 checks passed
@ldmonster ldmonster added the bug Something isn't working label May 28, 2026
@Glitchy-Sheep Glitchy-Sheep deleted the fix/object-default-map-overlay branch May 28, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants