Repository navigation
Conversation
…lse in schema format Add the IGNORED_VALUE and KEPT_VALUE schema warning types that Infrahub returns when a schema load ignores a null or keeps a stored value whose key the file leaves out. Keep optional: false on attributes in infrahubctl schema format --strip-defaults, because a schema load now keeps the stored optional value when the key is missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…format SchemaFile reads its file with a SafeLoader subclass that leaves out each mapping key whose value is a plain empty null scalar, so only a written null, ~ or NULL reads as None. Both reading paths (load_content and load_file_from_disk, single and multiple documents) use it; YamlFile and InfrahubFile keep the safe loader. infrahubctl schema format now writes a null it read as null, with the same text, and keeps an empty value empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… in schema format The formatter check read an empty key and a written null as the same value, so a rewrite between them passed unnoticed. A merge key copied empty keys from a mapping that was not yet constructed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, correct the changelog Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying infrahub-sdk-python with
|
| Latest commit: |
ea1957f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e94836e5.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://ifc-3676-schema-null-clears.infrahub-sdk-python.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## infrahub-develop #1582 +/- ##
====================================================
+ Coverage 88.52% 88.60% +0.08%
====================================================
Files 161 161
Lines 16994 16590 -404
Branches 2286 2222 -64
====================================================
- Hits 15044 14700 -344
+ Misses 1362 1321 -41
+ Partials 588 569 -19
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 6 files with indirect coverage changes 🚀 New features to boost your workflow:
|
4 of 5 tasks
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.
Why
A schema author who loads a schema file cannot remove a value stored on an attribute or relationship, such as
parameters.regex. IFC-3337 reports the problem. The server change in opsmill/infrahub#11795 makes an explicitnullclear the value. A key left out keeps the stored value.This pull request makes the SDK and
infrahubctlwork with that server change. It is tracked in IFC-3676.What changed
SchemaWarningTypehas two new values,ignored_valueandkept_value, so the client can parse a schema load response that contains these warnings.infrahubctlor a Git repository sync reads a schema file, a key with no value, such asparameters:, is left out, as if the file did not contain it. Only a writtennullor~clears a value.infrahub_sdk.yaml.SchemaLoaderis the loader ofSchemaFile. It drops each mapping key whose value is a plain empty scalar, at every depth, including keys copied in by a YAML merge key (<<:).null.!!nullwith no value, such asregex: !!null, is read in the same way as an empty key, and is left out.infrahubctl schema format:null,~orNULLas written, and keeps an empty value empty;SchemaLoader, so it stops with an error instead of turning an empty value intonullor back. It stops on a flow-style mapping with an empty value, such as{name: serial, kind: Text, description: }, because it cannot write that value back as empty;--strip-defaults, keepsoptional: falseon attributes, because a schema load keeps the storedoptionalvalue when the file leaves out the key.How to review
infrahub_sdk/yaml.py:SchemaLoaderand_is_empty_value.infrahub_sdk/ctl/schema_format.py: the null-preserving constructor and representer, and the check that usesSchemaLoader.tests/unit/sdk/test_yaml.py,tests/unit/ctl/test_schema_format.py, andtests/unit/ctl/test_schema_app.py::test_schema_load_leaves_out_keys_with_no_value, which checks the request thatinfrahubctl schema loadsends.How to test
Impact and rollout
parameters:, is now sent without that key. Against a server without the change in feat: clear a schema value by loading an explicit null [IFC-3337] infrahub#11795 the result is the same as before, because that server ignores anull.develop. That branch then moves thepython_sdksubmodule to the head ofinfrahub-develop.Checklist
🤖 Generated with Claude Code