fix(protocols): syncify all inherited bases with a Sync variant - #1331
Open
ogenstad wants to merge 2 commits into
Open
fix(protocols): syncify all inherited bases with a Sync variant#1331ogenstad wants to merge 2 commits into
ogenstad wants to merge 2 commits into
Conversation
Sync protocols generated by infrahubctl protocols only switched CoreNode, CoreProfile and CoreObjectTemplate to their Sync variant in an inheritance list. Any other core base (for example BuiltinIPAddress or LineageSource) kept its async name, so the sync class inherited async save/delete/create and type checked as needing an await. Collapse the two name sets into one that covers both peers and inheritance bases, switching any base that has a Sync counterpart.
Deploying infrahub-sdk-python with
|
| Latest commit: |
7c11882
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c645223f.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://pog-em-generated-sync-ihs-27.infrahub-sdk-python.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## infrahub-develop #1331 +/- ##
====================================================
+ Coverage 85.33% 85.35% +0.01%
====================================================
Files 148 148
Lines 14085 14082 -3
Branches 1936 1936
====================================================
- Hits 12020 12019 -1
+ Misses 1499 1498 -1
+ Partials 566 565 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
ogenstad
marked this pull request as ready for review
September 8, 2026 07:41
gmazoyer
approved these changes
Sep 8, 2026
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
Protocols generated for a sync client could inherit an async base class. In an inheritance list the generator only switched
CoreNode,CoreProfileandCoreObjectTemplateto their*Syncvariant. Every other core base (for exampleBuiltinIPAddressorLineageSource) kept its async name, so the generated sync class ended up with an async base in its MRO. Itssave,deleteandcreatethen type checked as async, and a correct sync call was reported as a missingawait. Only typing was affected; nothing changed at runtime.Closes #1276
What changed
infrahubctl protocolsnow inherit the*Syncvariant of every base that has one, not just the three special-cased names. Sync classes that inherited an async base (BuiltinIPAddress,BuiltinIPPrefix,LineageSource, ...) now expose the syncsave/delete/create._inherited_sync_names,_peer_sync_names) into a single_sync_namesused by both the inheritance and the peer branch.CORE_BASE_CLASS_TO_SYNCIFYis now only used to order the core bases last.What stayed the same
user_schema_async.txtdoes not change.ProtocolTarget.SDK_CORE, which generates the committedinfrahub_sdk/protocols.py) already switched every local base and is unchanged.How to review
The review surface is the golden fixture diff in
tests/fixtures/protocols_generator/user_schema_sync.txt: exactly 14 references change (BuiltinIPAddressandBuiltinIPPrefixonce each,LineageSourcetwelve times) and nothing else.How to test
Impact & rollout
save/delete/createnow exposes the sync ones. That is the intended correction and is called out in the changelog.Checklist
Summary by cubic
Fixes generated sync protocols that could inherit an async base class. Previously only
CoreNode,CoreProfile, andCoreObjectTemplatewere switched to their*Syncvariant in inheritance lists, so a class inheritingBuiltinIPAddressorLineageSourcekept asyncsave/delete/createand type checkers reported a missingawaiton correct sync calls. Now every inherited base with a*Syncvariant is switched, andCoreNodeis also switched as a relationship peer. Regenerating protocols may surface new type errors in code that relied on the old async signatures; runtime behavior is unchanged.Refactors
_sync_namesset used by both positions.CoreNodeexplicitly because it is the implicit base and is not part ofbase_protocols.CoreNodepeer.Written for commit 7c11882. Summary will update on new commits.