codeindex icon indicating copy to clipboard operation
codeindex copied to clipboard

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

Open scheidydude opened this issue 5 months ago • 0 comments

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.

scheidydude avatar Jun 19 '26 01:06 scheidydude