Skip to content

Git import loads objects before transforms, breaking same-repo refs #9406

@lancamat1

Description

@lancamat1

Component

Backend / Git integration (repository import)

Infrahub version

1.9.6

Current Behavior

During repository (git) import, objects/ are imported before the .infrahub.yml python_transforms are registered. An object that references a CoreTransformPython defined in the same repository therefore fails to resolve. For example, a CoreCustomWebhook with transformation: "MyTransform" aborts the import with:

Unable to find the node MyTransform / CoreTransformPython in the database.

The whole repository import aborts and the repository goes to sync_status: error-import. Because the failure happens during object import, the transforms/checks/generators are never registered either, so a retry can't converge.

The order is fixed in backend/infrahub/git/integrator.py (import_all, ~lines 201–216):

  1. import_schema_files
  2. import_all_graphql_query
  3. import_objects ← objects referencing a CoreTransformPython fail here
  4. import_all_python_filesimport_python_transforms (transforms registered here)

So any object referencing a repo-defined Python artifact (transforms, and presumably checks/generators registered in step 4) cannot be imported.

Expected Behavior

Either objects that reference repo-defined Python artifacts should resolve (e.g. register Python files before importing objects, or resolve such references in a dependency-aware / two-pass manner); or, at minimum, the importer should emit a clear, actionable error naming the offending object file and the unresolved transform, instead of a generic "Unable to find the node …" that aborts the entire import.

Steps to Reproduce

  1. Define a transform in .infrahub.yml:

    python_transforms:
      - name: MyTransform
        class_name: MyTransform
        file_path: transforms/my_transform.py
  2. Add an object file (e.g. objects/00_webhooks.yml) referencing it:

    apiVersion: infrahub.app/v1
    kind: Object
    spec:
      kind: CoreCustomWebhook
      data:
        - name: my-webhook
          event_type: infrahub.node.created
          node_kind: SomeNode
          url: https://example.com/webhook
          transformation: "MyTransform"
  3. Add the repository to Infrahub and let it sync.

  4. Observe sync_status: error-import with "Unable to find the node MyTransform / CoreTransformPython in the database." No transforms or webhooks are created.

Additional Information

Metadata

Metadata

Assignees

Labels

type/bugSomething isn't working as expected

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions