Skip to content

fix(server): name the path when the token signing key is not a file - #2392

Merged
yili-db merged 1 commit into
unitycatalog:mainfrom
Verlintas:fix/2364-directory-key-file
Dec 1, 2026
Merged

yili-db merged 1 commit into
unitycatalog:mainfrom
Verlintas:fix/2364-directory-key-file

Conversation

@Verlintas

@Verlintas Verlintas commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2364.

When server.token-signing-private-key-file points to a directory, the server currently reaches Files.readAllBytes and fails with a bare java.io.IOException: Is a directory, without naming the setting's path.

requireFile now also rejects a non-regular file with an IllegalStateException that names the absolute path:

Token signing key path is not a regular file: /path/to/signing-key

The existing unusable-key test table gets a directory row, so it asserts both the message and the path, and that no key material is written to the configuration folder. A separate test covers a non-directory parent, where Files.isRegularFile cannot determine the type; that path skips the new guard and lets readAllBytes report the real filesystem error.

Verification

  • build/sbt "server/testOnly io.unitycatalog.server.security.SecurityConfigurationTest" → 15 passed.
  • build/sbt "server/javafmt" → success.
  • The directory row fails against the old notExists-only check and passes with this change.

Not verified

The full server/test suite was not run locally; only the affected test class. javafmtAll pulls the Hadoop connector's artifacts and hit an unrelated Maven checksum error, so I scoped formatting to server/javafmt.

AI disclosure: this PR was authored with an AI coding agent (OpenCode, DeepSeek V4.1 Flash) under human supervision. The contributor is accountable for the change and its review. The commit is DCO signed off.

@Verlintas

Copy link
Copy Markdown
Contributor Author

Local verification: build/sbt "server/testOnly io.unitycatalog.server.security.SecurityConfigurationTest" → 11 passed; with the new isRegularFile check reverted, the directory row fails as expected. build/sbt "server/javafmt" passes.

GitHub has only started the DCO check so far. If this fork PR needs a maintainer to approve/trigger the workflow runs, could one of you kick it off?

AI disclosure: this reply was drafted by an AI coding agent (OpenCode, DeepSeek V4.1 Flash) under human supervision.

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks mostly good, just left one comment on Files.isRegularFile masking real filesystem errors.

if (Files.notExists(file)) {
throw new IllegalStateException("No token signing key file at " + file.toAbsolutePath());
}
if (!Files.isRegularFile(file)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to my understanding Files.isRegularFile(file) returns false both when the path isn't a regular file and when its type can't be determined (like an unreadable parent dir, a path through a regular file like parent-file/key.pem, or a symlink loop), so this hides the real IOException. should we gate it with Files.exists(file) so the read still reports the actual cause, and add a test for a non-directory parent?

-    if (!Files.isRegularFile(file)) {
+    if (Files.exists(file) && !Files.isRegularFile(file)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in feffd14: the guard now uses Files.exists(file) && !Files.isRegularFile(file), so a path whose type cannot be determined still falls through to the read and reports the real filesystem error. Added a test with a regular-file parent; it fails with the old ungated check and passes with the fix. SecurityConfigurationTest is now 12/12.

AI disclosure: this reply was drafted by an AI coding agent (OpenCode, DeepSeek V4.1 Flash) under human supervision.

@yili-db

yili-db commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

/review

@Verlintas
Verlintas force-pushed the fix/2364-directory-key-file branch from f121a86 to feffd14 Compare November 30, 2026 06:48
@yili-db

yili-db commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI Assisted] Approving. The message names the path, and a stat error now keeps its real cause: the guard is Files.exists(file) && !Files.isRegularFile(file), and the new parent-is-a-file test pins that behavior.

Optional, not blocking:

  • Consider Files.isDirectory(file) in place of the regular-file check, so a key supplied through a named pipe or device file keeps loading as it does on main. #2364 only asks for the directory case.
  • Javadoc on load (SecurityConfiguration.java, around line 85): with the current check, "must exist" could read "must exist and be a regular file". With the isDirectory change it would read "must exist and not be a directory".

@Verlintas

Copy link
Copy Markdown
Contributor Author

Thanks for the review and approval. The only failing job is unrelated to this diff: All tests (Spark 4.0.0, Delta 4.4.1) fails in SdkReadMetadataAccessControlTest.protocolsReturnMetadataWithoutDataCredentialsOrWrites with expected: 403 but was: 500 after 12.775s. The security tests changed here pass (SecurityConfigurationTest 12/12), and the same Spark job’s MySQL/Postgres variants pass. This looks like a transient/flaky failure in the credentials test.

I don't have permission to rerun the job; could a maintainer rerun the failed job? Happy to dig further if it reproduces.

AI disclosure: this reply was drafted by an AI coding agent (OpenCode, DeepSeek V4.1 Flash) under human supervision.

@yili-db

yili-db commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Please rebase

@Verlintas
Verlintas force-pushed the fix/2364-directory-key-file branch from feffd14 to 1eba21d Compare December 1, 2026 00:06
@Verlintas

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (80b1c5e) and resolved the SecurityConfigurationTest conflict by keeping both the new 512-bit key cases and the directory case. server/testOnly SecurityConfigurationTest → 15 passed; server/javafmt passes.

AI disclosure: this reply was drafted by an AI coding agent (OpenCode, DeepSeek V4.1 Flash) under human supervision.

@yili-db

yili-db commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

/review

@timothyw553

Copy link
Copy Markdown
Collaborator

LGTM, @Verlintas

@timothyw553 timothyw553 closed this Dec 1, 2026
@timothyw553 timothyw553 reopened this Dec 1, 2026
@timothyw553

Copy link
Copy Markdown
Collaborator

closing and reopening because of a CI issue

@yili-db
yili-db merged commit 7a3c269 into unitycatalog:main Dec 1, 2026
45 of 49 checks passed
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.

[Server] Name the path when the token signing key file is a directory

3 participants