Skip to content

terraform: node_type() misclassifies output-only files as "module" #6

Description

@scheidydude

node_type() in terraform_analyzer.py returns "module" as a catch-all fallback for any .tf file that has neither resources nor data sources. This means a root-level outputs.tf (which only declares output blocks) gets type="module" — the same type as a file physically inside a modules/ directory.

File: codeindex/analyzers/terraform_analyzer.py:82

def node_type(path: Path, has_resources: bool, has_data: bool) -> str:
    ...
    if has_resources or has_data:
        return "service"
    return "module"   # ← catches outputs.tf, locals.tf, etc.

Impact: Output-only files at the repo root are visually rendered as sub-modules in the explorer, misrepresenting their role in the graph. Note: "outputs" is not in _CONFIG_STEMS, so a root-level outputs.tf won't be caught by the "config" branch either.

Fix: Add "outputs" to _CONFIG_STEMS, or introduce a dedicated "output" node type for files that only contain output definitions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions