Skip to content

Handle empty manifest file #1807

Description

@tnatt

A user experienced a problem when there was an empty manifest file in the runpath, and this caused a fairly long traceback.
The empty file was most likely created after a manual stop of an execution in fmu-dataio.
We should handle an empty file, it could e.g. be done in the from_file() class method.

if manifest_path.exists():
logger.debug(f"Export manifest found at {manifest_path}")
manifest = ExportManifest.from_file(manifest_path)
else:
logger.debug(f"Export manifest not found at {manifest_path}, creating new one.")
manifest = ExportManifest()

  File "/project/fmu_for_ccs/users/fmmo/Kalundborg/26.0.3_fmu/ert/bin/scripts/fmuio_grids_test.py", line 56, in <module>
    main()
  File "/project/fmu_for_ccs/users/fmmo/Kalundborg/26.0.3_fmu/ert/bin/scripts/fmuio_grids_test.py", line 51, in main
    export_property_maps()
  File "/project/fmu_for_ccs/users/fmmo/Kalundborg/26.0.3_fmu/ert/bin/scripts/fmuio_grids_test.py", line 46, in export_property_maps
    out_path = export_data.export(surf)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/prog/res/komodo/2026.08.03-py312-rhel8/root/lib64/python3.12/site-packages/fmu/dataio/dataio.py", line 758, in export
    else export_with_metadata(self._export_config, obj)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/prog/res/komodo/2026.08.03-py312-rhel8/root/lib64/python3.12/site-packages/fmu/dataio/_export/core.py", line 60, in export_with_metadata
    _update_manifest_if_needed(export_config, outfile)
  File "/prog/res/komodo/2026.08.03-py312-rhel8/root/lib64/python3.12/site-packages/fmu/dataio/_export/core.py", line 69, in _update_manifest_if_needed
    update_export_manifest(outfile, casepath=export_config.runcontext.casepath)
  File "/prog/res/komodo/2026.08.03-py312-rhel8/root/lib64/python3.12/site-packages/fmu/dataio/manifest/_manifest.py", line 42, in update_export_manifest
    manifest = ExportManifest.from_file(manifest_path)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/prog/res/komodo/2026.08.03-py312-rhel8/root/lib64/python3.12/site-packages/fmu/dataio/manifest/_models.py", line 40, in from_file
    return cls.model_validate(json.load(file))
                              ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/__init__.py", line 293, in load
    return loads(fp.read(),
           ^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/decoder.py", line 338, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/decoder.py", line 356, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions