Skip to content

fix: report missing input files without stack traces#1036

Open
He-Pin wants to merge 1 commit into
databricks:masterfrom
He-Pin:fix/cli-missing-input-file
Open

fix: report missing input files without stack traces#1036
He-Pin wants to merge 1 commit into
databricks:masterfrom
He-Pin:fix/cli-missing-input-file

Conversation

@He-Pin

@He-Pin He-Pin commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Motivation

Missing CLI input files and binding files could leak raw Java exceptions or stack traces instead of clean user-facing errors. Malformed paths could also escape the normal error path.

Scenario sjsonnet master this PR
Missing input file Java NoSuchFileException stack trace Opening input file: missing.jsonnet: no such file or directory
Missing binding file Java file/path exception Opening binding file: missing.jsonnet: no such file or directory
Malformed binding path Java InvalidPathException / IllegalArgumentException detail Opening binding file: <message>

Modification

  • Wrap entry file path construction and read in mainConfigured.
  • Wrap parseBindings calls for ext-vars and TLAs.
  • Catch NoSuchFileException, IOException, and malformed-path IllegalArgumentException in the relevant error paths.
  • Add JVM CLI regression tests for missing input files and malformed binding file paths.

Result

  • CLI input and binding file failures return exit code 1 with concise diagnostics.
  • Tests assert stderr content and verify Java exception class names are not leaked.
  • Existing stdin and --exec paths are unchanged.

Verification

  • ./mill --no-daemon 'sjsonnet.jvm[3.3.8].test' sjsonnet.MainTests
  • ./mill --no-daemon 'sjsonnet.jvm[3.3.8].checkFormat'

@He-Pin He-Pin force-pushed the fix/cli-missing-input-file branch from 5cd11b6 to a23a523 Compare June 25, 2026 04:48
@He-Pin He-Pin marked this pull request as draft June 25, 2026 17:57
@He-Pin He-Pin marked this pull request as ready for review June 25, 2026 18:05
Motivation:

Missing input files, binding files, and malformed paths could escape CLI error handling and print Java exception details or stack traces.

Modification:

Wrap input loading and binding parsing in clean Either-returning error handling, including missing files, IO failures, and malformed path IllegalArgumentException. Add JVM CLI regression tests for missing input files and malformed binding file paths.

Result:

The CLI now reports concise Opening ... errors for these paths, and regression tests verify the errors do not leak Java exception class names.
@He-Pin He-Pin force-pushed the fix/cli-missing-input-file branch from 4e8555a to 56bc273 Compare June 25, 2026 19:04
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.

1 participant