Repository navigation
fix(schema): leave number pool ranges unset in the write model when they are not declared - #1424
Merged
polmichel merged 1 commit intoOct 15, 2026
Conversation
…hey are not declared A schema that leaves the ranges out of a NumberPool attribute's parameters now dumps without them, so a reload keeps the stored ranges, while an explicit empty list still declares zero ranges. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Deploying infrahub-sdk-python with
|
| Latest commit: |
8a04839
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a6cd43e8.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://pmi-number-pool-write-ranges.infrahub-sdk-python.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## infrahub-develop #1424 +/- ##
=================================================
Coverage 86.86% 86.86%
=================================================
Files 152 152
Lines 14813 14813
Branches 1982 1982
=================================================
Hits 12867 12867
Misses 1382 1382
Partials 564 564
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
polmichel
marked this pull request as ready for review
October 15, 2026 13:40
ajtmccarty
approved these changes
Oct 15, 2026
polmichel
added a commit
to opsmill/infrahub
that referenced
this pull request
Oct 15, 2026
#11089) * fix(sdk): leave number pool ranges unset in the generated write model A schema that leaves the ranges out of a NumberPool attribute's parameters no longer dumps as one that declares an empty range list. The read model is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore: regenerate the SDK write model, the OpenAPI schema and the REST types Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(schema): let a reloaded number pool declaration remove every range A NumberPool attribute reloaded with an explicit `ranges: []` and no start_range/end_range now declares zero ranges: the stored declaration drops its ranges or shorthand, the held-number check refuses the load while objects hold values, and the pool synchronizer empties the pool otherwise. Like every other omitted parameter, a reload that leaves the ranges out keeps the stored ones: omitted `parameters`, `parameters: {}`, and parameters setting no range key (for example only `allocation_scope`). An explicitly empty range list stays in the parameters dump, so a load merged from several files keeps it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(schema): cover number pool declarations reloaded with and without ranges Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore: point python_sdk at the merge of opsmill/infrahub-sdk-python#1424 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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
NumberPoolParametersWrite.rangesdefaulted to an empty list, so a schema that leaves the ranges out of a NumberPool attribute's parameters dumped the same as one that declaresranges: []. The Infrahub server builds its internal schema from that dump, and could not tell "keep the stored ranges" from "remove every range".Jira: IFC-3412
What changed
rangesislist[NumberPoolRangeWrite] | Noneand defaults toNone. A schema that does not declare the ranges dumps without them; an explicitranges: []stays in the dump.write.pyis generated byinvoke backend.generatein the Infrahub repository; the generator change and the submodule bump are in the companion Infrahub pull request.Related to opsmill/infrahub#11089
How to review
Read the
rangesfield ininfrahub_sdk/schema/generated/write.py, then the two tests intests/unit/test_schema_offline_validation.py.Tests
test_number_pool_without_any_range_spelling_leaves_the_range_fields_absentnow asserts thatrangesis absent from the dump; it fails with the previous write model.test_number_pool_explicit_empty_ranges_survive_the_dumps: an explicitranges: []stays in the server-side dump (exclude_none) and inSchemaRoot.to_schema_dict().Tests against the live application
Run with this branch installed as the SDK of a local Infrahub stack running opsmill/infrahub#11089:
client.schema.loadwith a NumberPool attribute declared withparameters: {}: the pool keeps its ranges. Withranges: []: the pool ends with zero ranges.SchemaRoot.model_validate(...).to_schema_dict(): without ranges,parametershas norangeskey and the load keeps the ranges; withranges=[],parametersis{"ranges": []}and the load removes them.infrahubctl schema loadon a directory of two YAML files:parameters: {}keeps the ranges,ranges: []removes them.🤖 Generated with Claude Code
Summary by cubic
Makes the schema write model distinguish a NumberPool attribute that leaves its ranges undeclared from one that explicitly declares
ranges: []. Previously both dumped the same empty list, so a schema reload could not tell "keep the stored ranges" from "remove every range" (IFC-3412).NumberPoolParametersWrite.rangesnow defaults toNoneand is omitted from dumps when unset, while an explicit empty list is preserved.Written for commit 8a04839. Summary will update on new commits.