Skip to content

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
apache:trunkfrom
arunk-kumar:HADOOP-19577-improve-wrong-fs-error
Open

HADOOP-19577. Improve error message when the path contains double slash without a preceding authority or bucket name.#8590
arunk-kumar wants to merge 1 commit into
apache:trunkfrom
arunk-kumar:HADOOP-19577-improve-wrong-fs-error

Conversation

@arunk-kumar

Copy link
Copy Markdown

Description of PR

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. FileSystem.checkPath then throws IllegalArgumentException with 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 reads Wrong 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 common scheme:////file typo 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 in Path'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 testWrongFsHintOnMissingAuthority in TestFileSystemCanonicalization covering the null-authority case. The existing exact-match assertion on the "Wrong FS" message in the same file is relaxed from assertEquals(...) to assertTrue(msg.startsWith(...)) so the primary contract is preserved without over-specifying wording. mvn -pl hadoop-common-project/hadoop-common test -Dtest=TestFileSystemCanonicalization passes 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:

  • Does the title or this PR starts with the corresponding JIRA issue id (e.g. 'HADOOP-17799. Your PR title ...')?
  • Object storage: have the integration tests been executed and the endpoint declared according to the connector-specific documentation?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE, LICENSE-binary, NOTICE-binary files?

AI Tooling

Contains content generated by Claude.

…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.
@hadoop-yetus

Copy link
Copy Markdown

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 1m 0s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 46m 34s trunk passed
+1 💚 compile 17m 35s trunk passed with JDK Ubuntu-21.0.11+10-1-24.04.2-Ubuntu
+1 💚 compile 18m 10s trunk passed with JDK Ubuntu-17.0.19+10-1-24.04.2-Ubuntu
+1 💚 checkstyle 1m 27s trunk passed
+1 💚 mvnsite 2m 0s trunk passed
+1 💚 javadoc 1m 26s trunk passed with JDK Ubuntu-21.0.11+10-1-24.04.2-Ubuntu
+1 💚 javadoc 1m 23s trunk passed with JDK Ubuntu-17.0.19+10-1-24.04.2-Ubuntu
+1 💚 spotbugs 3m 18s trunk passed
+1 💚 shadedclient 37m 26s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 1m 15s the patch passed
+1 💚 compile 16m 50s the patch passed with JDK Ubuntu-21.0.11+10-1-24.04.2-Ubuntu
+1 💚 javac 16m 50s the patch passed
+1 💚 compile 18m 9s the patch passed with JDK Ubuntu-17.0.19+10-1-24.04.2-Ubuntu
+1 💚 javac 18m 9s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 1m 25s the patch passed
+1 💚 mvnsite 1m 59s the patch passed
+1 💚 javadoc 1m 24s the patch passed with JDK Ubuntu-21.0.11+10-1-24.04.2-Ubuntu
+1 💚 javadoc 1m 21s the patch passed with JDK Ubuntu-17.0.19+10-1-24.04.2-Ubuntu
+1 💚 spotbugs 3m 25s the patch passed
+1 💚 shadedclient 36m 13s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 23m 35s hadoop-common in the patch passed.
+1 💚 asflicense 1m 11s The patch does not generate ASF License warnings.
238m 17s
Subsystem Report/Notes
Docker ClientAPI=1.55 ServerAPI=1.55 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8590/1/artifact/out/Dockerfile
GITHUB PR #8590
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux f8aed7c91241 5.15.0-177-generic #187-Ubuntu SMP Sat Apr 11 22:54:33 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / af55589
Default Java Ubuntu-17.0.19+10-1-24.04.2-Ubuntu
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.11+10-1-24.04.2-Ubuntu /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.19+10-1-24.04.2-Ubuntu
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8590/1/testReport/
Max. process+thread count 1427 (vs. ulimit of 10000)
modules C: hadoop-common-project/hadoop-common U: hadoop-common-project/hadoop-common
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8590/1/console
versions git=2.43.0 maven=3.9.15 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants