Skip to content

Raise a clear error when the dbt manifest is empty or invalid (LoadMode.DBT_MANIFEST) #2817

@tatiana

Description

@tatiana

Description

When using LoadMode.DBT_MANIFEST, Cosmos loads the manifest in DbtGraph.load_from_dbt_manifest via json.load(fp) on the configured manifest_path. If the file is empty, truncated, or not valid JSON, json.load raises a raw json.JSONDecodeError. Because this runs at DAG-parse time (inside DbtTaskGroup/DbtDag construction), the unhandled exception breaks DAG import and surfaces only as an opaque JSONDecodeError deep in Cosmos internals — with no indication of which manifest path failed or that the file is malformed.

Current behavior

A malformed/empty manifest.json fails with a bare traceback through cosmos/dbt/graph.pyload_from_dbt_manifestjson.load:

File ".../cosmos/airflow/task_group.py", line ..., in __init__
File ".../cosmos/converter.py", line ..., in __init__
    self.dbt_graph.load(method=..., execution_mode=...)
File ".../cosmos/dbt/graph.py", line ..., in load_from_dbt_manifest
    manifest = json.load(fp)
...
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The error gives no hint about the cause or which path was read.

Expected behavior

Validate the manifest before parsing and raise an actionable CosmosLoadDbtException that includes the path and the underlying cause, e.g.:

Failed to load dbt manifest at <path>: file is empty or not valid JSON (<original error>)

Proposed implementation

  • In load_from_dbt_manifest, check the file exists / is non-empty and wrap the json.load call to re-raise as CosmosLoadDbtException with the manifest path and original error.
  • Add a test with an empty/truncated manifest fixture.

Notes

Related parsing work: #2294, #2486. This is a robustness / error-message improvement on the LoadMode.DBT_MANIFEST path (not a performance change).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcustomer requestAn Astronomer customer made requested thisgood first issueGood for newcomers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions