Skip to content

fix: Initialize IaC providers for dump subcommand - #87

Merged
tvansteenburgh merged 1 commit into
mainfrom
ajk/fix/initialize-provider-for-dump
Oct 7, 2026
Merged

tvansteenburgh merged 1 commit into
mainfrom
ajk/fix/initialize-provider-for-dump

Conversation

@ajkerrigan

@ajkerrigan ajkerrigan commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

what

Call c7n-left's initialize_iac() to load the Terraform provider as part of running sinistral dump.

why

For a case where c7n-left dump -d . succeeds, sinistral dump -d . fails with:

AttributeError: 'NoneType' object has no attribute 'initialize'

Because sinistral bypasses some top-level CLI logic that c7n-left runs by default, so it handles provider registration for sinistral run while loading policies. It never loads the provider for the dump case.

testing

Tested locally, added a regression test.

docs

N/A

c7n-left registers its IaC providers in its cli group callback, which
is skipped when sinistral invokes the dump subcommand directly. Call
initialize_iac() before dumping, default the directory to ".", and
raise a usage error when no supported IaC files are found.

Also avoid appending duplicate params on repeated make_parser calls.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ajkerrigan
ajkerrigan requested a review from a team as a code owner October 7, 2026 20:14

@tvansteenburgh tvansteenburgh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @ajkerrigan

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant User
    participant Sinistral as Sinistral CLI (dump cmd)
    participant LeftWrapper as LeftWrapper (click)
    participant C7NLeft as c7n-left CLI (left_dump)
    participant Provider as IaC Provider Registry
    participant FS as Filesystem

    Note over Sinistral,Provider: sinistral dump invokes c7n-left dump directly,<br/>bypassing c7n-left top-level CLI setup

    User->>Sinistral: invoke dump subcommand
    Sinistral->>LeftWrapper: make_parser(ctx)
    LeftWrapper->>LeftWrapper: merge left_dump params<br/>(skip duplicates)
    LeftWrapper-->>Sinistral: parser ready

    Sinistral->>Provider: initialize_iac()
    Provider->>Provider: register Terraform provider<br/>and any IaC providers

    alt directory param missing
        Sinistral->>Sinistral: default directory to "."
    end

    Sinistral->>FS: get_provider(directory)
    FS-->>Sinistral: provider for IaC type (or None)

    alt no supported IaC files
        Sinistral-->>User: UsageError: No supported IaC files found
    else provider available
        Sinistral->>C7NLeft: invoke left_dump(ctx)
        C7NLeft->>FS: parse .tf/.json files
        FS-->>C7NLeft: resource graph
        C7NLeft-->>Sinistral: dump output (JSON)
        Sinistral-->>User: graph + variables
    end

    Note over Sinistral,FS: Regression tests invoke CLI in a subprocess<br/>to avoid import side-effect registration</br>from prior in-process c7n-left usage
Loading

Re-trigger cubic

@tvansteenburgh
tvansteenburgh merged commit 89096e7 into main Oct 7, 2026
10 checks passed
@tvansteenburgh
tvansteenburgh deleted the ajk/fix/initialize-provider-for-dump branch October 7, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants