HADOOP-19577. Improve error message when the path contains double slash without a preceding authority or bucket name.#8590
Open
arunk-kumar wants to merge 1 commit into
Conversation
…sh without a preceding authority or bucket name.
When java.net.URI reinterprets a stray '//' in a Path as the authority delimiter (see HADOOP-8087), the intended host or bucket may be silently dropped, and FileSystem.checkPath then prints a 'Wrong FS' message that no longer contains the caller's input.
This change adds a diagnostic hint to the exception message when the path's URI scheme is present, the authority is null, and the FileSystem has a non-null authority. This covers the common 'scheme:////file' typo case (Path.toString becomes 'scheme:/file', authority is null). The primary 'Wrong FS: <path>, expected: <fs-uri>' text is preserved so existing callers and log parsers keep working.
Known limitation: joining a Path with a child that begins with '//' (e.g. new Path(new Path("s3://bucket/"), "//file")) results in the child's leading segment being promoted to the authority position with a non-null value; this case is not covered here because the URI is not distinguishable at check time from a plain wrong-host root path without false positives. A follow-up in Path's constructors would be the right place to catch that shape.
A new unit test in TestFileSystemCanonicalization covers the hint; its existing exact-match assertion on the primary text is relaxed to a startsWith check.
|
🎊 +1 overall
This message was automatically generated. |
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.
Description of PR
When
java.net.URIreinterprets a stray//in aPathas the authority delimiter (see HADOOP-8087), the intended host or bucket may be silently dropped.FileSystem.checkPaththen throwsIllegalArgumentExceptionwith a "Wrong FS" message that no longer contains the caller's input, which makes the cause hard to diagnose.For example,
new Path("hdfs:////some/file")parses to a URI with a null authority, and the current message readsWrong FS: hdfs:/some/file, expected: hdfs://cluster/with no clue that a leading double slash was the cause.This PR appends a short diagnostic hint to the exception message when three conditions all hold: the path URI has a scheme, the path URI's authority is null, and this FileSystem has a non-null authority. The primary
Wrong FS: <path>, expected: <fs-uri>text is preserved, so existing callers and log parsers keep working. Users hitting the commonscheme:////filetypo now see a message that names the cause and references HADOOP-8087.The hint is deliberately narrow. Joining a Path with a child that begins with
//, e.g.new Path(new Path("s3://bucket/"), "//file"), promotes the child's first segment to the authority position with a non-null value; that shape is not distinguishable at check time from a plain wrong-host root path (hdfs://wronghost/) without false positives. A follow-up inPath's constructors would be the right place to catch that shape, since the original input string is only available there.How was this patch tested?
Added a new unit test
testWrongFsHintOnMissingAuthorityinTestFileSystemCanonicalizationcovering the null-authority case. The existing exact-match assertion on the "Wrong FS" message in the same file is relaxed fromassertEquals(...)toassertTrue(msg.startsWith(...))so the primary contract is preserved without over-specifying wording.mvn -pl hadoop-common-project/hadoop-common test -Dtest=TestFileSystemCanonicalizationpasses 17/17 (16 existing + 1 new). Locally validated the message end-to-end with a stub FileSystem driver against the null-authority case, the child-//displacement case, and a plain scheme/host mismatch — the hint fires only for the null-authority case.For code changes:
LICENSE,LICENSE-binary,NOTICE-binaryfiles?AI Tooling
Contains content generated by Claude.