Repository navigation
Conversation
…port keeps [IFC-3669] Regenerated with uv run invoke backend.generate: InfrahubSchemaWrite gains the optional infrahub_version field, and contract.py gains KEEP_IN_EXPORT_FIELDS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…C-3669] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s [IFC-3669] Regenerated from the Infrahub schema definitions, which now mark choices, read_only and unique on attributes, and cardinality, identifier and optional on relationships. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…FC-3669] infrahubctl schema export and InfrahubSchema.export now call GET /api/schema/export and return its document as a SchemaExportDocument. The CLI gains --mode and --single-file, splits the document by namespace with split_by_namespace, and writes only the keys the server returned. A server without the endpoint gives an error that names the first release with it; any other error response is reported as the server returned it. The client-side export rules and their models are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt [IFC-3669] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… export [IFC-3669] An Infrahub server without the export endpoint answers with "Unable to find the schema 'export' in the registry", so the SDK now matches that message and names the first release with the endpoint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…export comment [IFC-3669] State which attribute kinds write regex, min_length and max_length under parameters, and regenerate the KEEP_IN_EXPORT_FIELDS comment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…IFC-3669] The server answers a namespace that does not exist on the branch, or a restricted one, with a 404 whose errors name the namespace in extensions.namespace. The SDK raises SchemaNamespaceNotFoundError for that response, and URLNotFoundError for a 404 that names no namespace, such as Infrahub's answer to an unknown URL. infrahubctl schema export prints one error line per namespace and exits with code 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s [IFC-3669] - An unknown branch raises BranchNotFoundError again, as the export did before it used the server endpoint. - A document with a value this SDK version cannot read raises InvalidResponseError instead of a pydantic ValidationError, and infrahubctl prints it, and a JsonDecodeError, without a traceback. - SchemaNamespaceNotFoundError and VersionNotSupportedError survive pickle and copy. - A namespace error without a text message is named in a fallback message, so the CLI never prints an empty error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… schema export [IFC-3669] - A 401 or 403 from the export endpoint raises AuthenticationError, as the GraphQL paths do, and infrahubctl prints it as an authentication failure. - infrahubctl escapes the directory, file and namespace names it prints, so a name with square brackets no longer fails a finished export. - The command help mentions the --single-file layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t files [IFC-3669] infrahubctl schema export wrote its files from the SDK write models, which drop the fields they do not declare. With an SDK older than the server, a field that a later Infrahub release adds was left out of the files with no message, and a load of the files lost it. The CLI now checks the response as before, then writes the JSON body the server returned. split_by_namespace takes and returns dicts and copies every top-level field to each namespace document. InfrahubSchema.export still returns a SchemaExportDocument. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 of 5 tasks
Deploying infrahub-sdk-python with
|
| Latest commit: |
efeebb7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8df3296b.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://po-ifc-3669-schema-export-cl.infrahub-sdk-python.pages.dev |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## infrahub-develop #1554 +/- ##
====================================================
+ Coverage 87.92% 87.99% +0.07%
====================================================
Files 157 157
Lines 15853 15716 -137
Branches 2162 2112 -50
====================================================
- Hits 13938 13829 -109
+ Misses 1336 1324 -12
+ Partials 579 563 -16
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 3 files with indirect coverage changes 🚀 New features to boost your workflow:
|
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
infrahubctl schema exportwrote values Infrahub generated and elements the schema owner did not define, so the file did not load into another instance without editing. The export rules were written by hand in the SDK and fell behind the schema model (spec).Infrahub 1.13.0 adds
GET /api/schema/export, which builds the export on the server (opsmill/infrahub#11772). This pull request makes the SDK andinfrahubctl schema exportuse that endpoint and removes the client-side export rules.Jira: IFC-3669, part of IFC-2964.
Breaking changes to the public API
The SDK
AGENTS.mdlists changes to public API signatures under "Ask first". The feature owner accepted these on 2026-11-27, and the changelog fragments list them:infrahub_sdk.schema, with no deprecation period:schema_to_export_dict,RESTRICTED_NAMESPACES,NamespaceExportandSchemaExport(changelog/+schema-export-client-rules.removed.md).InfrahubSchema.exportandInfrahubSchemaSync.exportreturn aSchemaExportDocumentinstead of aSchemaExport(changelog/+schema-export-document.changed.md).exportandinfrahubctl schema exportraiseVersionNotSupportedErrorwith the message that Infrahub 1.13.0 or later is required. Before, they exported on the client.BRIEFmode,infrahubctl schema exportwrites files that differ from earlier versions.changelog/+schema-export-endpoint.changed.mdlists each difference.What changed
Behavior:
exportcallsGET /api/schema/exportwithbranch,namespacesand a newmodeargument (SchemaExportMode.BRIEFby default, orFULL), and returns the server's document as aSchemaExportDocument. This model is a subclass ofInfrahubSchemaWritewith a requiredinfrahub_version.infrahubctl schema exporthas two new options:--mode BRIEF|FULL;--single-file, which writes all namespaces toschema.yml.Without
--single-file, it writes one file per namespace, as before.The CLI writes the JSON body the server returned, after the SDK has checked it, instead of the SDK models. The files therefore keep a field that a later Infrahub release adds and this SDK version does not know.
split_by_namespacetakes and returns dicts for this reason.Errors of the export are raised as SDK exceptions:
AuthenticationError;BranchNotFoundError;VersionNotSupportedError;extensions.namespace: the newSchemaNamespaceNotFoundError, with one message per namespace;URLNotFoundError;InvalidResponseError;ApiError.The CLI prints one
Error:line per namespace and exits with code 1.InfrahubSchemaWriteaccepts aninfrahub_versionfield, sovalidate_schemaandinfrahubctl schema loadaccept an exported file.KEEP_IN_EXPORT_FIELDSin the generatedcontract.pylists the fields aBRIEFexport keeps. Infrahub'suv run invoke backend.generatewrites it.What stayed the same:
infrahubctl schema loadand the other schema commands.exportin Python still returns the model, which drops fields this SDK version does not know; only the CLI keeps them.How to review
infrahub_sdk/schema/__init__.py:_parse_export_response, which maps the responses to exceptions, and_export_payload, which the CLI uses.infrahub_sdk/schema/export.pyand theexportcommand ininfrahub_sdk/ctl/schema.py.infrahub_sdk/schema/generated/contract.pyandwrite.pyare generated from Infrahub.How to test
httpx_mock. There is no integration test against a running server yet.Impact & rollout
infrahubctl schema exportneeds Infrahub 1.13.0 or later.python_sdkpointer to this branch's merge commit.Checklist
uv run towncrier create ...)docs/docs/infrahubctl/infrahubctl-schema.mdxis regenerated, and the user guide isdocs/docs/schema/export.mdxin opsmill/infrahub🤖 Generated with Claude Code