fix(git): register transforms before objects during repository import [#9406]#9460
Conversation
There was a problem hiding this comment.
No issues found across 15 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would require human review. This reorders the repository import sequence to register transforms before objects, which is a critical business logic change in the core import pipeline that could break imports if incorrect, so it requires human review.
Re-trigger cubic
4b95d9e to
d5b9b6d
Compare
polmichel
left a comment
There was a problem hiding this comment.
Thanks for your work and the fix on this issue, @lancamat1!
I've left comments that are mainly about code conventions and maintainability. We can also take over this work if you'd prefer.
One additional thing to note: we prefer to target the stable branch for bug fixes.
Of course, this makes sense only if this is a bug. However, the fixed.md part of the changelog seems to indicate that. In that case adding the "type/bug" label to the Github issue would also be required.
We want to target stable branch so customers don't have to upgrade to the next minor version to get the fix and only upgrade to the next patch version which is less impacting.
d5b9b6d to
2a83b95
Compare
|
Thanks so much for the thorough and kind review, @polmichel — really appreciate the time you took, and every pointer was spot-on. Pushed an update addressing all of them:
Thanks again — happy to iterate on anything else! |
2a83b95 to
5c6898f
Compare
ajtmccarty
left a comment
There was a problem hiding this comment.
@ogenstad left a comment on the bug this PR fixes that is worth considering (#9406 (comment)). it looks like we probably need a more robust importing system that allows objects to reference transforms and vice versa
|
Thanks @ajtmccarty! The fixed-ordering approach here was agreed as part of IFC-2669. It covers both reference directions in the current schema — objects → transforms (the reported case) and generators/artifacts → groups, which are objects and so import after. A more flexible / dependency-aware importer would be a larger piece of work; happy to open a follow-up issue to track it if we'd like to pursue it. |
I was actually thinking about artifact definitions that refer to a group (same with generator definitions) but transforms should be fine to import earlier than we do now. |
polmichel
left a comment
There was a problem hiding this comment.
LGTM on the backend side, I'll just ask the front-end team to validate the .gitignore modification before you merge. Fyi, I usually "squash" the commits (this is one of the option of the merge button) so that only one commit remains once the PR is merged. This gives a cleaner git history, I think. Thank you for the fix.
I've posted two optional comments but it would be great if you can:
- move the comment closer to the code it explains
- remove useless instructions from the test
5c6898f to
dcec6df
Compare
…#9406] During repository import, objects were imported before Python transforms were registered, so an object referencing a same-repo CoreTransformPython (for example a CoreCustomWebhook.transformation) aborted the whole import with "Unable to find the node ... / CoreTransformPython in the database" and left the repository in error-import. Reorder import_objects_from_files so Python and Jinja2 transforms are registered before objects, while checks, generator definitions and artifact definitions stay after objects (their targets reference groups created from the repository's own object files). Tests: add a dedicated, isolated integration_docker fixture (same-repo-references) and TestSameRepoReferences that imports it through the full stack and asserts the webhook resolves its same-repo Python transform (US1) and a generator resolves a target group defined as a same-repo object (US2). The test fails against the released 1.9.6 image with the documented error and passes against a source build. Co-Authored-By: Claude Opus 4.8 <[email protected]> [skip ci] — only removes a .gitignore line; code identical to the previously CI-green commit.
dcec6df to
94f7bd8
Compare
Summary
During repository import,
objects/were imported before the.infrahub.ymlPython transforms were registered. An object referencing aCoreTransformPythondefined in the same repository (e.g. aCoreCustomWebhookwithtransformation: "MyTransform") therefore aborted the entire import with:…leaving the repository in
sync_status: error-import. Because the failure happened during object import, transforms/checks/generators were never registered either, so a retry could not converge.Fixes #9406 (IFC-2669).
Change
Reorder
InfrahubRepositoryIntegrator.import_objects_from_filesso the end-to-end order is:Transforms move before objects so same-repo references resolve. Generators and artifact definitions stay after objects because their
targetsreference groups created from the repository's own object files — moving them up would trade one failure for another. This splits the previously-bundledimport_all_python_filescall accordingly (the method is retained for its existing integration-test caller).No schema, GraphQL, or database changes.
Tests
Extends the existing full-stack
integration_dockercar-dealershipfixture andtest_propose_change_repository.py(no new fixture repo):CoreCustomWebhookreferencing the repo's existingWebhookTransformerPython transform; assertstransformationresolves after import.CoreStandardGroupdefined as a repo object plus a generator definition targeting it; asserts the generator'stargetsresolves to the same-repo group (guards the objects-before-generators side of the ordering).Validation:
:local):test_propose_change_repository.py4/4 pass.1.9.6image (no fix):test_load_initial_datafails with the exact issue errorUnable to find the node WebhookTransformer / CoreTransformPython— confirming the tests are genuine regression guards.Notes
package-lock.jsontofrontend/app/.gitignore(this project uses pnpm; an stray npm lockfile kept appearing).dev/specs/ifc-2669-fix-import-order/contains the spec/plan/tasks design record for the ticket.🤖 Generated with Claude Code
Summary by cubic
Fixes repository import ordering so Python and Jinja2 transforms register before objects, allowing same-repo references (e.g.,
CoreCustomWebhook.transformation) to resolve. Keeps checks, generator definitions, and artifact definitions after objects so theirtargetsto repo-defined groups still resolve. Aligns with IFC-2669.InfrahubRepositoryIntegrator.import_objects_from_filesto: Schemas → GraphQL queries → Transforms (Python + Jinja2) → Objects → Checks/Generators/Artifacts.import_all_python_files; tests now callimport_python_check_definitionsandimport_python_transformsexplicitly.same-repo-referencesfixture and full-stackintegration_dockertest (TestSameRepoReferences) that verifies a webhook resolves its same-repo transform and a generator resolves a same-repo group.Written for commit 94f7bd8. Summary will update on new commits.