Skip to content

[PreProcessor] Report config errors through the normal failure path - #844

Merged
gmechali merged 5 commits into
datacommonsorg:masterfrom
gmechali:config-errors
Nov 11, 2026
Merged

gmechali merged 5 commits into
datacommonsorg:masterfrom
gmechali:config-errors

Conversation

@gmechali

@gmechali gmechali commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Today a bad config.json fails in Runner.__init__, before run()'s failure handling, so it writes no report.json, no ingestion report and no handshake. The ingestion workflow gets no structured error.

Changes

  • Runner.__init__ only sets up the output store, reporter and summary generator. run() calls the new _load_config() inside its existing try, which reads the config and opens the input stores (through a small _open_input_store helper). A config failure therefore produces the same report.json, ingestion_report.json and {"status": "FAILURE", "errors": [...]} handshake as any other failure. No schema or field changes.
  • Config errors (validation, bad JSON, non-object config, missing dataDownloadUrl) carry INVALID_CONFIGURATION. A missing config file stays GENERIC_ERROR.
  • run() uses e.error_type when set, instead of always GENERIC_ERROR. This changes the reported type of three existing failures:
Failure Before After
Undefined provenance GENERIC_ERROR MISSING_PROVENANCE
Provenance without a source GENERIC_ERROR MISSING_SOURCE
Provenance without a namespace prefix GENERIC_ERROR INVALID_CONFIGURATION

Verification

Six scenarios ran through the real Runner (testsuite harness: WORKFLOW_EXECUTION_ID set, output and handshake on fake GCS), on master and on this PR:

Scenario master this PR
Valid config SUCCESS Byte-identical
Unknown key Nothing written FAILURE, INVALID_CONFIGURATION
Malformed JSON Nothing written FAILURE, INVALID_CONFIGURATION
No config.json Nothing written FAILURE, GENERIC_ERROR
Undefined provenance GENERIC_ERROR MISSING_PROVENANCE (only change)
Multi-import, bad subdir config Nothing written FAILURE, INVALID_CONFIGURATION, message names the subdir config
  • Config failures use the existing failure handshake; no new fields. UN 10-import subset: identical output.
  • Tests: handshake_error_types=() expectations now expect INVALID_CONFIGURATION (or GENERIC_ERROR for missing files). New: test_invalid_config_is_reported_like_any_failed_run pins the handshake, report.json and ingestion report for a bad subdirectory config. Lint clean; full suite passes.

Stack: this PR → #845

A bad config.json used to fail in Runner.__init__, before run()'s failure
handling, so it wrote no report.json, no ingestion report and no workflow
handshake: the ingestion workflow got no structured error.

Runner now sets up the output store in __init__ and reads the config at the
start of run(). A config that fails to load or validate is reported like any
other failed run, with the same report.json, ingestion report and FAILURE
handshake shapes. Config errors carry the INVALID_CONFIGURATION type; a
missing config file stays a GENERIC_ERROR.

run() now uses an error's error_type for the handshake instead of always
GENERIC_ERROR, so MetadataValidator errors are reported as
INVALID_CONFIGURATION, MISSING_PROVENANCE and MISSING_SOURCE as intended.
@codacy-production

codacy-production Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 9 minor

Alerts:
⚠ 9 issues (≤ 0 issues of at least minor severity)

Results:
9 new issues

Category Results
Documentation 8 minor
CodeStyle 1 minor

View in Codacy

🟢 Metrics 4 complexity

Metric Results
Complexity 4

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the runner and configuration parsing to ensure that configuration errors are properly caught and reported as structured INVALID_CONFIGURATION failures rather than generic errors. It updates the initialization order in Runner to set up output directories and reporters before loading the configuration, and updates corresponding test cases to assert the correct handshake error types. The review feedback suggests a cleaner, more type-safe approach to error handling by defining a custom ConfigurationError exception class instead of dynamically attaching custom attributes to standard built-in exceptions like ValueError and JSONDecodeError.

Comment thread simple/stats/data.py Resolved
Comment thread simple/stats/runner.py Resolved
Comment thread simple/stats/config.py Resolved
@gmechali
gmechali requested a review from pranj-s November 10, 2026 21:07
Comment thread simple/testsuite/test_config.py Resolved
@gmechali
gmechali merged commit d965689 into datacommonsorg:master Nov 11, 2026
9 of 10 checks passed
@gmechali
gmechali deleted the config-errors branch November 11, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants