[
https://issues.apache.org/jira/browse/HADOOP-19577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18094277#comment-18094277
]
ASF GitHub Bot commented on HADOOP-19577:
-----------------------------------------
arunk-kumar opened a new pull request, #8590:
URL: https://github.com/apache/hadoop/pull/8590
### 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:
- [x] 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](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`,
`NOTICE-binary` files?
### AI Tooling
Contains content generated by Claude.
> Improve error message when the path contains double slash without a preceding
> authority or bucket name
> ------------------------------------------------------------------------------------------------------
>
> Key: HADOOP-19577
> URL: https://issues.apache.org/jira/browse/HADOOP-19577
> Project: Hadoop Common
> Issue Type: Bug
> Reporter: Ganesha S
> Priority: Minor
>
> Currently, we display the following error message when a path contains a
> double slash without a preceding authority or bucket name.
> {code:java}
> java.lang.IllegalArgumentException: Wrong FS: s3://test_file.json.gz,
> expected: s3://test_bucket/ at
> org.apache.hadoop.fs.FileSystem.checkPath(FileSystem.java:824) at
> org.apache.hadoop.fs.FileSystem.makeQualified(FileSystem.java:683){code}
> The path used in the above case is s3://test_bucket{*}//{*}test_file.json.gz.
> It is expected that Hadoop will treat the path name preceding the double
> slash (//) as a bucket or authority because, according to HADOOP-8087, a
> relative reference that begins with two slash characters is termed a
> network-path reference.
> Created this Jira to evaluate printing the full path in the error message or
> to revise the error message when the path contains a double slash without a
> preceding authority or bucket name for easier debugging.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]