Serialize YAML null as string "null" in nested references#207
Open
Serialize YAML null as string "null" in nested references#207
null as string "null" in nested references#207Conversation
Until now, a reference with a default value which is a reference that resolves to a YAML `null` value would result in a YAML string `"None"` when the resolution falls back on the default value. The cause for this is that we serialized `Value::Null` to `"None"` until now to preserve compatibility with Python's `str()` for nested reference lookups (since Python Reclass just uses `str()` to serialize nested references). This commit changes the serialization of `Value::Null` to `"null"` which is preserved as a YAML `null` when a reference default value is defined as a nested reference that resolves to YAML `null`. Conversely, any existing nested references that expect YAML `null` to be serialized as `None` will break with this change.
null as string "null" in nested referencesnull as string "null" in nested references
This comment was marked as outdated.
This comment was marked as outdated.
e91d02f to
adb73c4
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This compat flag changes reclass-rs's serialization of YAML `null` values in nested references to emit string "None" instead of the new default of string "null". Unless your inventory depends on this behavior we strongly recommend not using the compatibility mode.
adb73c4 to
0b4365a
Compare
Benchmark for bb3ff00Click to view benchmark
|
haasad
approved these changes
Apr 29, 2026
Member
haasad
left a comment
There was a problem hiding this comment.
LGTM (although my understanding of this codebase and rust in general is limited)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Until now, we serialized
Value::Nullto"None"to preserve compatibility with Python'sstr()in nested reference lookups (since kapicorp-reclass just usesstr()to serialize nested references).However, this causes issues when using a nested reference that resolves to a YAML
nullvalue as a default value for a reclass reference: until now such a reference would result in a YAML string"None"when the resolution falls back on the default value (see parameternullrefintests/inventory-reference-default-values/nodes/n12.ymlfor an example reference that exhibits this behavior).This PR changes the default serialization of
Value::Nullwhile resolving nested references to"null". This value is preserved as a YAMLnullwhen a resolved nested reference is parsed again because it's used as a reference default value.Note that this change breaks existing nested references for inventories that expect YAML
nullto be serialized asNone. However, to accommodate users of such inventories, the PR also introduces a new compatibility flagNestedReferenceNullAsNonewhich changes reclass-rs's serialization of YAMLnullvalues in nested references to emit string "None" to preserve kapicorp-reclass compatibility. Unless your inventory depends on this behavior we strongly recommend not using the compatibility mode.Follow-up / fix for #194
Marked as
breakingbecause the new default behavior (without the compatibility flag) is a breaking change for existing inventories that expect nested references to resolve YAMLnullvalues as string "None".Checklist
bug,enhancement,documentation,change,breaking,dependency,internalas they show up in the changelog