You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "RohanExploit (via GitHub)" <gi...@apache.org> on 2026/08/16 05:54:19 UTC

[PR] [Improve][Connector-V2] Diagnose Hadoop client version mismatch on Kerberos FileSystem init [seatunnel]

RohanExploit opened a new pull request, #11823:
URL: https://github.com/apache/seatunnel/pull/11823

   ### Purpose of this pull request
   
   Closes the diagnosability gap in #10172. On a Kerberos-enabled HDFS connection, `FileSystem.get()` builds a `DFSClient` that reaches into Hadoop internals (e.g. `FsTracer`) whose signatures have changed across Hadoop releases. When the Hadoop client jars resolved at runtime — a `provided` dependency supplied by the deployment environment, not bundled here — don't match what SeaTunnel was built against, the failure surfaces as a raw `NoSuchMethodError`/`NoClassDefFoundError` deep inside Hadoop's own code, with nothing pointing at the real cause.
   
   This wraps that call and rethrows an `IOException` naming the likely cause and the version this connector targets (Hadoop 3.1.4, per `seatunnel-hadoop3-3.1.4-uber`). The working path is untouched — this is diagnostic only, not a behavior change.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No change on success. On this specific failure the user sees a clear `IOException` explaining the likely version mismatch instead of a bare JVM linkage error.
   
   ### How was this patch tested?
   
   Two unit tests in `HadoopFileSystemProxyTest`: one simulates a `NoSuchMethodError` and asserts it is rewritten to the diagnostic `IOException` with the original preserved as the cause (fails before this change, passes after); one asserts the success path passes through unchanged.
   
   ---
   Disclosure: this change was AI-assisted (Claude). I reviewed it and can speak to the reasoning.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2] Diagnose Hadoop client version mismatch on FileSystem init [seatunnel]

Posted by "RohanExploit (via GitHub)" <gi...@apache.org>.
RohanExploit commented on PR #11823:
URL: https://github.com/apache/seatunnel/pull/11823#issuecomment-5343391546

   Thanks @DanielLeens, and no need to frame Issue 1 as your miss. You were right that the narrow two type catch was a coverage gap, and you are right now that `LinkageError` is broader than "version mismatch". Both things are true, the second only shows up once the first is fixed. All three items are addressed at `a0f6014`.
   
   Issue 1. I took Option A rather than Option B, and I want to explain why since you offered both. Narrowing back to the four mismatch types would let `UnsatisfiedLinkError` and friends escape unwrapped, which puts those users back in exactly the position #10172 describes, a bare linkage error out of Hadoop internals with nothing pointing anywhere. The problem was never that the catch was too wide, it was that the message asserted one cause with more confidence than the catch could justify. So the catch still covers the whole family and the message now says "may indicate", names the other realistic possibilities, and points at the cause. Combining that with Issue 3 does most of the work, because the concrete error is now in the message itself:
   
   ```
   Failed to initialize Hadoop FileSystem (UnsatisfiedLinkError: no hadoop in java.library.path).
   This may indicate a Hadoop client version mismatch between SeaTunnel and the Hadoop jars
   resolved at runtime (...), or another classpath or linkage problem such as a missing native
   library or an unreadable class file. This connector is built and tested against Hadoop 3.1.4
   (see seatunnel-hadoop3-3.1.4-uber in the reactor pom); check that the Hadoop client jars on
   the classpath are compatible with that version, and see the cause below for the specific failure.
   ```
   
   A native library failure now reads as a native library failure while still getting the classpath framing, which neither option gave on its own. If you would still rather have the narrow catch I will switch it, it is a small change.
   
   Issue 2. The version moved into `TARGET_HADOOP_VERSION`, and the uber artifact name is derived from it as `"seatunnel-hadoop3-" + TARGET_HADOOP_VERSION + "-uber"` so the two cannot drift apart. Grepping the file for `3.1.4` now returns exactly one hit, the constant.
   
   Issue 3. Done via a small `describeLinkageError` helper that renders `Type: message`, falling back to just the type when the error carries no message, so the text never contains a stray "null".
   
   Tests are up to 13, two new ones:
   
   * `testWrapClasspathMismatchNamesTheConcreteLinkageFailure` throws an `UnsatisfiedLinkError` and asserts both the type and its message appear in the rewritten text. This is the one that covers the non mismatch subtypes you raised.
   * `testWrapClasspathMismatchHandlesLinkageErrorWithoutMessage` throws a `NoClassDefFoundError` with no message and asserts the type is still named and the text does not contain "null".
   
   The shared `assertRewrittenAsDiagnosticIOException` helper now also asserts the concrete type is named, so all four original rewrite tests cover the inlining too.
   
   I checked the new tests actually bite rather than assuming it. Dropping the null guard from `describeLinkageError` fails `testWrapClasspathMismatchHandlesLinkageErrorWithoutMessage` with `expected: <false> but was: <true>`, then passes again once restored. `spotless:check` is clean and all 13 tests pass locally on JDK 11, with the one pre-existing Windows only skip.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2] Diagnose Hadoop client version mismatch on FileSystem init [seatunnel]

Posted by "RohanExploit (via GitHub)" <gi...@apache.org>.
RohanExploit commented on PR #11823:
URL: https://github.com/apache/seatunnel/pull/11823#issuecomment-5339972863

   @DanielLeens thanks for the detailed review.
   
   Issue 1 was a real scope miss on my part, not a deliberate narrowing. The linkage failure happens while `FileSystem.get()` builds the `DFSClient` and `FsTracer`, which has nothing to do with Kerberos, so wrapping only that branch left the other two call sites just as opaque as before. I went with Option A. `initialize()` and `initializeWithRemoteUserLogin()` now both go through `getFileSystemWithDiagnostics()`. I checked the propagation instead of assuming it: `initialize()` is `@SneakyThrows` and `HadoopLoginFactory.LoginFunction#run` declares `throws Exception`, so both were a straight swap. Grepping for `FileSystem.get(configuration)` in the file now returns one hit, the call inside the helper.
   
   Issue 2 is fixed by widening the catch to `LinkageError`. `NoSuchFieldError` and `IncompatibleClassChangeError` come out of the same jar mismatch, and `LinkageError` still leaves `OutOfMemoryError` and `StackOverflowError` alone. The `IOException` message body is unchanged.
   
   Javadoc is on both `getFileSystemWithDiagnostics` and `wrapClasspathMismatch` now, replacing the old block comment. It says the failure is not specific to any one authentication mode and that all three call sites route through the helper, and it refers to `LinkageError` rather than `NoSuchMethodError`.
   
   New tests:
   
   * `testWrapClasspathMismatchRewritesNoClassDefFoundError`
   * `testWrapClasspathMismatchRewritesNoSuchFieldError`
   * `testWrapClasspathMismatchRewritesIncompatibleClassChangeError`
   * `testWrapClasspathMismatchDoesNotSwallowUnrelatedErrors`, which throws an `OutOfMemoryError` and asserts the same instance comes back out unwrapped. That one is what makes the widening to `LinkageError` reviewable.
   * `testWrapClasspathMismatchPropagatesIOExceptionUnchanged`, where a plain `IOException` from the supplier comes back identical with a null cause.
   
   The four rewrite tests share a private `assertRewrittenAsDiagnosticIOException(LinkageError)` helper that asserts the original is the cause and the message names the Hadoop client version mismatch. The existing `NoSuchMethodError` test uses it too. All plain `@Test`, no I/O, no sleeps, no new dependencies. I sanity checked them by putting the old two type catch back: `NoSuchFieldError` and `IncompatibleClassChangeError` fail, everything else passes.
   
   You were right that the title was narrower than the mechanism. Retitled it and rewrote the PR body around all three call sites.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2] Diagnose Hadoop client version mismatch on Kerberos FileSystem init [seatunnel]

Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on PR #11823:
URL: https://github.com/apache/seatunnel/pull/11823#issuecomment-5307461793

   Good job.
   
   Thanks a lot for your valuable contribution to Apache SeaTunnel!
   
   To pass the automated CI checks for this PR, could you please enable CI workflows in your forked repository first? You can refer to the check run link below as a reference for the required CI configuration  https://github.com/apache/seatunnel/pull/11823/checks?check_run_id=95123508319
   
   If you run into any trouble enabling CI or encounter related errors during the process, feel free to leave a comment here. Contributors are always ready to offer help~
   
   <img width="2412" height="1472" alt="image" src="https://github.com/user-attachments/assets/6abd2ea1-da45-4d78-a81c-0158f2d7a851" />


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2] Diagnose Hadoop client version mismatch on FileSystem init [seatunnel]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #11823:
URL: https://github.com/apache/seatunnel/pull/11823#discussion_r3811674103


##########
seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/hadoop/HadoopFileSystemProxy.java:
##########
@@ -469,6 +469,69 @@ private void initializeWithKerberosLogin() throws IOException, InterruptedExcept
         log.info("Create FileSystem success with Kerberos: {}.", hadoopConf.getKerberosPrincipal());
     }
 
+    /**
+     * Creates the Hadoop {@link FileSystem} for the given configuration, rewriting a classpath
+     * mismatch into a diagnosable failure.
+     *
+     * <p>{@code FileSystem.get()} constructs a {@code DFSClient}, which reaches into Hadoop
+     * internals (e.g. {@code FsTracer}) whose method signatures have changed across Hadoop
+     * releases. If the Hadoop client jars actually resolved at runtime (this dependency is {@code
+     * provided}, so it comes from the deployment environment, not this project's shaded jar) don't
+     * match what SeaTunnel was built against, that surfaces as a raw {@link LinkageError} deep in
+     * Hadoop's own code with no indication of the real cause.
+     *
+     * <p>Nothing about that failure is specific to one authentication mode, so all three {@code
+     * FileSystem.get()} call sites in this class -- the plain path, the Kerberos path and the
+     * remote-user path -- are routed through here.
+     *
+     * @param configuration Hadoop configuration to build the filesystem from
+     * @return the filesystem for {@code configuration}
+     * @throws IOException if the filesystem cannot be created, including the diagnostic rewrite of
+     *     a Hadoop client version mismatch
+     */
+    private static FileSystem getFileSystemWithDiagnostics(Configuration configuration)
+            throws IOException {
+        return wrapClasspathMismatch(() -> FileSystem.get(configuration));
+    }
+
+    @FunctionalInterface
+    interface FileSystemSupplier {
+        FileSystem get() throws IOException;
+    }
+
+    /**
+     * Invokes {@code supplier} and rewrites a {@link LinkageError} raised while loading or linking
+     * Hadoop classes into an {@link IOException} that names the likely Hadoop client version
+     * mismatch, keeping the original error as the cause.
+     *
+     * <p>Only {@code LinkageError} is caught -- {@code NoSuchMethodError}, {@code
+     * NoClassDefFoundError}, {@code NoSuchFieldError} and {@code IncompatibleClassChangeError} are
+     * all plausible symptoms of the same jar mismatch -- so unrelated errors such as {@code
+     * OutOfMemoryError} still propagate untouched, as does an {@link IOException} raised by the
+     * supplier itself.
+     *
+     * @param supplier filesystem acquisition to guard
+     * @return whatever {@code supplier} returns
+     * @throws IOException the supplier's own {@code IOException}, or a diagnostic one wrapping a
+     *     {@code LinkageError}
+     */
+    static FileSystem wrapClasspathMismatch(FileSystemSupplier supplier) throws IOException {
+        try {
+            return supplier.get();
+        } catch (LinkageError e) {
+            throw new IOException(
+                    "Failed to initialize Hadoop FileSystem, likely due to a Hadoop client "
+                            + "version mismatch between SeaTunnel and the Hadoop jars resolved "
+                            + "at runtime (the Hadoop dependency here is `provided`, so it comes "
+                            + "from your deployment environment, not a bundled version). This "
+                            + "connector is built and tested against Hadoop 3.1.4 (see "
+                            + "seatunnel-hadoop3-3.1.4-uber in the reactor pom); check that the "
+                            + "Hadoop client jars on the classpath are compatible with that "
+                            + "version.",
+                    e);

Review Comment:
   The message hardcodes the target Hadoop version (`3.1.4`) and an internal artifact name; this will become stale the next time the connector’s Hadoop baseline changes. Consider centralizing the target Hadoop version into a single constant (or a build-time injected property) and referencing that constant here so updates don’t require hunting through strings.



##########
seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/hadoop/HadoopFileSystemProxy.java:
##########
@@ -469,6 +469,69 @@ private void initializeWithKerberosLogin() throws IOException, InterruptedExcept
         log.info("Create FileSystem success with Kerberos: {}.", hadoopConf.getKerberosPrincipal());
     }
 
+    /**
+     * Creates the Hadoop {@link FileSystem} for the given configuration, rewriting a classpath
+     * mismatch into a diagnosable failure.
+     *
+     * <p>{@code FileSystem.get()} constructs a {@code DFSClient}, which reaches into Hadoop
+     * internals (e.g. {@code FsTracer}) whose method signatures have changed across Hadoop
+     * releases. If the Hadoop client jars actually resolved at runtime (this dependency is {@code
+     * provided}, so it comes from the deployment environment, not this project's shaded jar) don't
+     * match what SeaTunnel was built against, that surfaces as a raw {@link LinkageError} deep in
+     * Hadoop's own code with no indication of the real cause.
+     *
+     * <p>Nothing about that failure is specific to one authentication mode, so all three {@code
+     * FileSystem.get()} call sites in this class -- the plain path, the Kerberos path and the
+     * remote-user path -- are routed through here.
+     *
+     * @param configuration Hadoop configuration to build the filesystem from
+     * @return the filesystem for {@code configuration}
+     * @throws IOException if the filesystem cannot be created, including the diagnostic rewrite of
+     *     a Hadoop client version mismatch
+     */
+    private static FileSystem getFileSystemWithDiagnostics(Configuration configuration)
+            throws IOException {
+        return wrapClasspathMismatch(() -> FileSystem.get(configuration));
+    }
+
+    @FunctionalInterface
+    interface FileSystemSupplier {
+        FileSystem get() throws IOException;
+    }
+
+    /**
+     * Invokes {@code supplier} and rewrites a {@link LinkageError} raised while loading or linking
+     * Hadoop classes into an {@link IOException} that names the likely Hadoop client version
+     * mismatch, keeping the original error as the cause.
+     *
+     * <p>Only {@code LinkageError} is caught -- {@code NoSuchMethodError}, {@code
+     * NoClassDefFoundError}, {@code NoSuchFieldError} and {@code IncompatibleClassChangeError} are
+     * all plausible symptoms of the same jar mismatch -- so unrelated errors such as {@code
+     * OutOfMemoryError} still propagate untouched, as does an {@link IOException} raised by the
+     * supplier itself.
+     *
+     * @param supplier filesystem acquisition to guard
+     * @return whatever {@code supplier} returns
+     * @throws IOException the supplier's own {@code IOException}, or a diagnostic one wrapping a
+     *     {@code LinkageError}
+     */
+    static FileSystem wrapClasspathMismatch(FileSystemSupplier supplier) throws IOException {
+        try {
+            return supplier.get();
+        } catch (LinkageError e) {
+            throw new IOException(
+                    "Failed to initialize Hadoop FileSystem, likely due to a Hadoop client "
+                            + "version mismatch between SeaTunnel and the Hadoop jars resolved "
+                            + "at runtime (the Hadoop dependency here is `provided`, so it comes "
+                            + "from your deployment environment, not a bundled version). This "
+                            + "connector is built and tested against Hadoop 3.1.4 (see "
+                            + "seatunnel-hadoop3-3.1.4-uber in the reactor pom); check that the "
+                            + "Hadoop client jars on the classpath are compatible with that "
+                            + "version.",

Review Comment:
   The rewritten `IOException` message doesn’t include the specific linkage failure (error class + original message). Including something like the `LinkageError`’s concrete type and message (while still keeping it as the cause) would make the diagnostic more actionable from logs where the cause stacktrace might be truncated.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2] Diagnose Hadoop client version mismatch on FileSystem init [seatunnel]

Posted by "DanielLeens (via GitHub) via commits" <co...@seatunnel.apache.org>.
DanielLeens commented on PR #11823:
URL: https://github.com/apache/seatunnel/pull/11823#issuecomment-7207699464

   The CI fact cited previously has changed: the Apache check now explicitly reports a **missing fork Build** for this head (ACTION_REQUIRED), rather than merely an absent check. This is not proof of a workflow waiting for maintainer approval. Please open the contributor fork Actions page, enable workflows if requested, then dispatch the existing Build workflow on this PR branch and confirm its head SHA. If dispatch is refused by an account/repository restriction, the owner must resolve that restriction before a run can start. A missing run has no demonstrated source-level upstream fix; syncing or adding dependencies solely to chase this status is not indicated. 
   
   The existing requirement to assert the actual result remains open.
   
   Check evidence: [Build](https://github.com/apache/seatunnel/runs/136867711387).
   
   Unchanged head `c247095d66c3c008a1c7a2c1d8834b2c5998ecf9`; base `dev`; compare `diverged`, ahead 7 / behind 295. This is a CI/merge-state correction, not another full source review. No local build/test/runtime execution was performed. Daniel has READ permission; effective maintainer approval and historical-review dismissal remain separate actions.
   
   Current snapshot (2026-11-27T02:56:32.549555+00:00): Signal pull request update: SUCCESS; Build: ACTION_REQUIRED; merge state `BLOCKED`; review decision `REVIEW_REQUIRED`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2] Diagnose Hadoop client version mismatch on FileSystem init [seatunnel]

Posted by "RohanExploit (via GitHub)" <gi...@apache.org>.
RohanExploit commented on PR #11823:
URL: https://github.com/apache/seatunnel/pull/11823#issuecomment-5339973272

   @davidzollo thanks. GitHub Actions is enabled in my fork now, so CI runs on this push. I also rebased the branch onto current `dev`, and @DanielLeens review feedback is addressed in the same push. I'll join the #contributors channel on Slack.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2] Diagnose Hadoop client version mismatch on FileSystem init [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #11823:
URL: https://github.com/apache/seatunnel/pull/11823#issuecomment-6285113272

   Pushed `02387c9a40f` on top of your branch, @RohanExploit: a merge of the current `dev` plus one test-only commit.
   
   - Merge conflict in `HadoopFileSystemProxy.java` (this PR's `TARGET_HADOOP_VERSION` / `TARGET_HADOOP_UBER_ARTIFACT` constants vs `dev`'s new `DEFAULT_BUFFER_SIZE` / `APPEND_TARGET_LENGTH_MARKER_SUFFIX`): resolved by keeping both blocks; no logic line changed.
   - Issue 1 from my last review: the nine `wrapClasspathMismatch` unit tests (four `LinkageError` subtype rewrites, the `OutOfMemoryError` and `IOException` pass-throughs, the two concrete-failure-naming tests and the success pass-through) are restored in `HadoopFileSystemProxyTest` exactly as they were at `1f91908ff1`, next to the `hasAnyFile` and close-reuse tests that came from `dev`.
   
   Only `spotless` was run locally. Your fork did not create a Build run for this push, so I started a verification run of the same head on my fork: https://github.com/DanielLeens/seatunnel/actions?query=branch%3Apr11823-verify-02387c9a40f. If no run appears on your side, please start one from the Actions tab ("Run workflow" on Build) so the apache `Build` check can pick it up.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2] Diagnose Hadoop client version mismatch on Kerberos FileSystem init [seatunnel]

Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on PR #11823:
URL: https://github.com/apache/seatunnel/pull/11823#issuecomment-5307502930

   Thanks for your contribution! This is a solid addition to the project, and your attention to detail really shows. Contributors like you are what keep this community moving forward. Feel free to keep the PRs coming — we're always glad to have you here!
   
   Please ignore the following message if you have joined in the Slack~
   ```
   To facilitate focused communication among contributors, we’ve created a brand-new dedicated #contributors channel in official Slack workspace.
   Slack workspace link: https://s.apache.org/seatunnel-slack
   
   This channel is designed for technical discussions, feature design brainstorming, roadmap sync and direct communication with project core Contributors. Everyone who contributes code, docs, test cases or community ideas is warmly invited to join, share thoughts and collaborate together under The Apache Way. Welcome to join 😄
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2] Diagnose Hadoop client version mismatch on FileSystem init [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #11823:
URL: https://github.com/apache/seatunnel/pull/11823#issuecomment-6285140940

   Correction: the test file at `02387c9a40f` had a stray closing brace at the end (my restore appended the class terminator twice), which would have failed compilation. Fixed in `117ef5c1195`, now pushed to your branch; the verification run moved to https://github.com/DanielLeens/seatunnel/actions?query=branch%3Apr11823-verify-117ef5c1195 and the earlier one is cancelled. Sorry for the noise.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org