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.py → load_from_dbt_manifest → json.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).
Description
When using
LoadMode.DBT_MANIFEST, Cosmos loads the manifest inDbtGraph.load_from_dbt_manifestviajson.load(fp)on the configuredmanifest_path. If the file is empty, truncated, or not valid JSON,json.loadraises a rawjson.JSONDecodeError. Because this runs at DAG-parse time (insideDbtTaskGroup/DbtDagconstruction), the unhandled exception breaks DAG import and surfaces only as an opaqueJSONDecodeErrordeep in Cosmos internals — with no indication of which manifest path failed or that the file is malformed.Current behavior
A malformed/empty
manifest.jsonfails with a bare traceback throughcosmos/dbt/graph.py→load_from_dbt_manifest→json.load:The error gives no hint about the cause or which path was read.
Expected behavior
Validate the manifest before parsing and raise an actionable
CosmosLoadDbtExceptionthat includes the path and the underlying cause, e.g.:Proposed implementation
load_from_dbt_manifest, check the file exists / is non-empty and wrap thejson.loadcall to re-raise asCosmosLoadDbtExceptionwith the manifest path and original error.Notes
Related parsing work: #2294, #2486. This is a robustness / error-message improvement on the
LoadMode.DBT_MANIFESTpath (not a performance change).