fix(cli): clean errors for malformed inputs and honest dbt-gate exit codes - #351
Open
kevincostner17 wants to merge 1 commit into
Open
kevincostner17 wants to merge 1 commit into
kevincostner17 wants to merge 1 commit into
Conversation
…codes Malformed config/suite/manifest files (#289): - freshdata clean --config: invalid YAML/JSON, a non-object top level, a non-object "clean"/"enterprise" section, and unknown keys (TypeError from MaskingRule(**rule) or merge_options) now raise ValueError naming the file. main() reports them as one-line "freshdata: error: ..." with exit 1, the existing convention for bad input files. PyYAML's multi-line message is collapsed to one line. - freshdata validate: ValidationSuite.from_dict rejects non-mappings with ValueError, and --contract checks the top level too, so non-object rule files exit 2 ("could not load rules") instead of 1 ("validation failed"). - dbt-gate: catch (OSError, ValueError), so invalid JSON, a directory path and non-manifest files are one-line errors with exit 1, like a missing manifest. Non-UTF-8 stdout (#295): - Add _safe_print(), which reprints with errors="replace" on UnicodeEncodeError. It is used for the clean summary/notes and the validate verdict, so a cp1252/ascii stdout no longer turns a passed gate (with outputs already written) into exit 1. EnterpriseResult.summary is unchanged. Nothing gated must not pass (#296): - gate_manifest raises ValueError when the file has no "nodes" mapping. - all_passed is now false when models_processed == 0; dbt-gate prints a "no models were gated" note to stderr, and --fail exits 1. Ephemeral models (#249): - gate_manifest skips models with config.materialized == "ephemeral" or config.enabled == false and lists them under a new "skipped" key. They are not counted in models_processed or failed_models. Closes #289 Closes #295 Closes #296 Closes #249
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
FreshData benchmark report —
|
| fixture | n_rows | n_cols | p50 s | p95 s | peak MB | repair % | false-repair % | preserve % | trust | monotonic | export % |
|---|
Authored-code reduction (Metric 6)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
freshdata clean --confignow reports these as a one-linefreshdata: error: ...naming the file, with exit 1 (the existing convention for bad input files):clean/enterprisesection that isn't an objectfreshdata validate --suite/--contractwith a non-object file now exits 2 ("could not load rules") instead of 1 ("validation failed").ValidationSuite.from_dictrejects non-mappings withValueError.dbt-gatenow catches(OSError, ValueError). Invalid JSON, a directory path, or a file that isn't a manifest now gives a one-linedbt-gate: error: ...with exit 1, like a missing manifest._safe_printretries witherrors="replace"onUnicodeEncodeError. It's used for thecleansummary and notes and thevalidateverdict, so a cp1252/ascii stdout no longer turns a passed gate (outputs already written) into exit 1.dbt-gate --failpassed when nothing was gated.gate_manifestraisesValueErrorwhen the file has nonodesmapping (e.g.run_results.json).all_passedisfalsewhenmodels_processed == 0.dbt-gateprints a "no models were gated" note to stderr, and--failexits 1.config.materialized == "ephemeral"orconfig.enabled == falseare skipped. They're listed under a new"skipped"summary key and not counted inmodels_processedorfailed_models.Behaviour changes:
dbt-gatesummary has a newskippedkey.all_passedis false when nothing was gated.validateexits 2 for non-object rule files.Tests
tests/test_cli_malformed_inputs.py:validateexits 2 for non-object--suiteand--contractfilesValidationSuite.from_dictrejects non-mappingscleanandvalidateon an ascii stdout: a passed gate exits 0, a failed gate still exits 1tests/test_integrations/test_dbt.py:ValueError--failexits 1--failexiting 0 when the real tables passVerification
ruff check .: all checks passedmypy src/freshdata: no issues found in 202 source files-m "not online and not large"), py3.12 / pandas 2.3.3: 4272 passed, 6 skippedCloses #289
Closes #295
Closes #296
Closes #249