Skip to content

Conversation

@yu-iskw
Copy link
Contributor

@yu-iskw yu-iskw commented Oct 24, 2025

It would sound natural to return a failure exit code, if there are any violations and changes with dbt-autofix deprecations.

dbt-autofix 0.14.0 return the exit code 0, even if any changes exist.

$ dbt-autofix --version
dbt-autofix 0.14.0

$ dbt-autofix deprecations --all
Warning: Path /Users/yu/local/src/jaffle_shop/tests does not exist
Warning: Path /Users/yu/local/src/jaffle_shop/analysis does not exist
Warning: Path /Users/yu/local/src/jaffle_shop/snapshots does not exist

Refactored /Users/yu/local/src/jaffle_shop/models/schema.yml:
  restructure_yaml_keys
    Model 'customers' - Moved all the meta fields under config.meta and 
merged with existing config.meta.

$ echo $?
0

@yu-iskw yu-iskw marked this pull request as ready for review October 24, 2025 01:19
@yu-iskw yu-iskw requested a review from a team as a code owner October 24, 2025 01:19
@b-per
Copy link
Collaborator

b-per commented Oct 24, 2025

Thanks! I think we just need to be a bit careful with this change as we also run dbt-autofix as part of some flows and wouldn't want to break those.

@yu-iskw
Copy link
Contributor Author

yu-iskw commented Oct 24, 2025

@b-per

I see. What about adding a command line options to configure the exit code, say about --fail-on-fix. If we don't pass the option, the exit code 0 is returned as the current version. But if we pass it, the exit code 1 is returned. What do you think?

@dbeatty10
Copy link
Contributor

@b-per

I see. What about adding a command line options to configure the exit code, say about --fail-on-fix. If we don't pass the option, the exit code 0 is returned as the current version. But if we pass it, the exit code 1 is returned. What do you think?

Instead of --fail-on-fix, we should use --check (off by default).

This would align with other similar tools (according to ChatGPT):

Tool Uses --check (or similar) Exit Code When Changes Are Made (Default Mode) Notes
Black --check 0 Returns 1 in --check mode if reformat needed; 123 on internal error.
isort --check 0 Non-zero in --check mode if imports are unsorted.
Prettier --check 0 Exits 1 in --check mode if any files are unformatted.
rustfmt --check 0 Exits 1 in --check mode if files would be reformatted.
Ruff --check 0 Exits non-zero if files would be reformatted; --exit-non-zero-on-fix affects linter mode.

Signed-off-by: Yu Ishikawa <[email protected]>
@yu-iskw yu-iskw requested a review from chayac as a code owner December 18, 2025 03:22
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.

3 participants