Repository navigation
fix(server): name the path when the token signing key is not a file - #2392
Conversation
|
Local verification: 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
left a comment
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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)) {There was a problem hiding this comment.
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.
|
/review |
f121a86 to
feffd14
Compare
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[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 theisDirectorychange it would read "must exist and not be a directory".
|
Thanks for the review and approval. The only failing job is unrelated to this diff: 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. |
|
Please rebase |
Signed-off-by: Verlintas <[email protected]>
feffd14 to
1eba21d
Compare
|
Rebased onto current AI disclosure: this reply was drafted by an AI coding agent (OpenCode, DeepSeek V4.1 Flash) under human supervision. |
|
/review |
|
LGTM, @Verlintas |
|
closing and reopening because of a CI issue |
Fixes #2364.
When
server.token-signing-private-key-filepoints to a directory, the server currently reachesFiles.readAllBytesand fails with a barejava.io.IOException: Is a directory, without naming the setting's path.requireFilenow also rejects a non-regular file with anIllegalStateExceptionthat names the absolute path: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.isRegularFilecannot determine the type; that path skips the new guard and letsreadAllBytesreport the real filesystem error.Verification
build/sbt "server/testOnly io.unitycatalog.server.security.SecurityConfigurationTest"→ 15 passed.build/sbt "server/javafmt"→ success.notExists-only check and passes with this change.Not verified
The full
server/testsuite was not run locally; only the affected test class.javafmtAllpulls the Hadoop connector's artifacts and hit an unrelated Maven checksum error, so I scoped formatting toserver/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.