fix(aitools): non-zero exit when discover-schema has any failed table#5116
Open
jamesbroadhead wants to merge 1 commit intomainfrom
Open
fix(aitools): non-zero exit when discover-schema has any failed table#5116jamesbroadhead wants to merge 1 commit intomainfrom
jamesbroadhead wants to merge 1 commit intomainfrom
Conversation
Per-table failures were rendered into stdout but the command still returned nil from RunE, so the process exited 0 even when every table failed. Scripts and CI couldn't detect failure without parsing output for "Error discovering ...", which is exactly the kind of err.Error() string-matching the repo's style guide forbids. Extract the loop into runDiscoverSchemas which returns (output, anyFailed). RunE prints the output and returns root.ErrAlreadyPrinted when anyFailed is true so cobra produces a non-zero exit without re-printing the errors. Behavior preserved: per-table failures still don't abort the others. Co-authored-by: Isaac
Waiting for approvalBased on git history, these people are best suited to review:
Eligible reviewers: Suggestions based on git history. See OWNERS for ownership rules. |
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
databricks aitools tools discover-schema TABLE...rendered per-table failures into stdout but always returnednilfrom RunE. Even when every table failed, the process exited0, so scripts and CI couldn't detect failure without grepping output for"Error discovering "— exactly the kind oferr.Error()string-matching the repo's style guide forbids.Extract the loop into
runDiscoverSchemaswhich returns(output, anyFailed). RunE prints the output and returnsroot.ErrAlreadyPrintedwhenanyFailedis true so cobra produces a non-zero exit without re-printing the per-table errors. Behavior preserved: one bad table still doesn't abort the others.Spotted via multi-model code review on #4917 (GPT 5.4). Pre-existing in #5097, not introduced by #4917 — sending as a separate small fix per the "keep PRs focused" rule.
Test plan
go test ./experimental/aitools/cmd/(new tests:TestRunDiscoverSchemasFlagsTableFailureForExitCode,TestRunDiscoverSchemasAllSucceedReturnsFalse).databricks aitools tools discover-schema doesnt.exist.foo; echo $?should now print1.0.This pull request and its description were written by Isaac.