Fix transpile hanging with incomplete config in non-interactive mode#2326
Open
moomindani wants to merge 2 commits intodatabrickslabs:mainfrom
Open
Fix transpile hanging with incomplete config in non-interactive mode#2326moomindani wants to merge 2 commits intodatabrickslabs:mainfrom
moomindani wants to merge 2 commits intodatabrickslabs:mainfrom
Conversation
…atabrickslabs#2086) When `transpile` is run without required configuration values and stdin is not a TTY (e.g. when driven by the Databricks CLI), the code previously fell through to `input()` which hung indefinitely because the Databricks CLI intercepts stdin. Add `_is_interactive` to `_TranspileConfigChecker` (defaults to `sys.stdin.isatty()`) and a `_require_interactive()` guard that raises a clear `ValueError` before each prompt call when not running interactively. This covers: `--input-source`, `--output-folder`, `--source-dialect` (when multiple dialects are available), `--transpiler-config-path` (when multiple transpilers match a dialect), and missing required transpiler options. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ARGS Avoids recreating the dict on every call to _handle_missing_transpiler_option. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2326 +/- ##
==========================================
+ Coverage 66.41% 66.46% +0.04%
==========================================
Files 99 99
Lines 9094 9110 +16
Branches 974 976 +2
==========================================
+ Hits 6040 6055 +15
- Misses 2878 2879 +1
Partials 176 176 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Fixes #2086.
When
databricks labs lakebridge transpileis run with missing required configuration (e.g. no--input-source), the checker falls back to prompting the user viainput(). However, the Databricks CLI intercepts stdin for thetranspilecommand because it expects a JSON summary written to stdout — so theinput()call blocks forever with no output or error message. The user has to^Cto escape.Stack trace from the issue showing where it hangs:
Root cause
_TranspileConfigCheckerusesPrompts.question()/Prompts.choice()as a fallback whenever a required configuration value is absent. These methods callinput()which blocks on stdin. When the Databricks CLI runstranspilenon-interactively, stdin is not connected to the user's terminal, so the call hangs indefinitely.Fix
_is_interactive: boolto_TranspileConfigChecker(defaults tosys.stdin.isatty(), injectable viais_interactivekwarg for testing)._require_interactive(msg): raises a descriptiveValueErrorimmediately if not in a TTY — before anyinput()is reached._require_interactive()before each of the 5 prompt sites:--input-sourcemissing"Missing required value for '--input-source': use '--input-source' to specify..."--output-foldermissing"Missing required value for '--output-folder': use '--output-folder' to specify...""Multiple source dialects are available: use '--source-dialect' to specify one of: ...""Multiple transpilers are available for dialect X: use '--transpiler-config-path'...""Missing required transpiler option 'X': use '--target-technology' to provide it."(orinstall-transpileif no CLI arg exists)_TRANSPILER_OPTION_CLI_ARGSclass-level constant mapping known transpiler option flags to their CLI argument names (overrides-file→--overrides-file,target-tech→--target-technology)._handle_missing_transpiler_option(addressed by this PR).Changes to existing tests
Two existing tests used
MockPromptsto simulate interactive prompting and previously passed locally only because a developer terminal has a TTY (sys.stdin.isatty()→True). They would silently fail in CI:mock_cli_transpile_no_configfixture: usesMockPromptsto answer dialect/path prompts → patchedisatty=True.test_transpile_prints_errors: usesMockPromptsto answer anexperimentaloption prompt → patchedisatty=True.New tests
test_transpile_non_interactive_missing_input_source--input-sourceabsenttest_transpile_non_interactive_missing_output_folder--output-folderabsenttest_transpile_non_interactive_missing_source_dialect_with_multiple_dialectstest_transpile_non_interactive_missing_required_transpiler_option_with_cli_arg--target-technologyhint whentarget-techoption is absent🤖 Generated with Claude Code