Skip to content

Parse native Java Dags and show their source - #73843

Merged
jason810496 merged 8 commits into
jason/lang-sdk-e2e/02-importer-registryfrom
jason/lang-sdk-e2e/04-java-dag-importer
Oct 1, 2026
Merged

jason810496 merged 8 commits into
jason/lang-sdk-e2e/02-importer-registryfrom
jason/lang-sdk-e2e/04-java-dag-importer

Conversation

@jason810496

@jason810496 jason810496 commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Stack (bottom to top): #73841, #74004, #73842, #73843, #73844, #73845, #73846, #73847

Why

With this PR, JavaCoordinator parses the native Dags a bundle JAR declares, and the Code view shows their Java source.

What changes

  • Which JARs. A JavaCoordinator without jars_root parses each .jar whose manifest sets Main-Class (matching main_class if set) in the Dag bundles it reads, skipping thin-bundle dependency JARs. An unreadable JAR is kept so its parse reports the error.
  • Parse command. The task command, java -classpath <bundle JARs> <jvm_args> <Main-Class>, with the same schema version lookup. A JAR it cannot run gets an import error.
  • Manifest reader. Tasks and parses now read manifests per the JAR specification (CR, LF or CRLF, folded lines, main section only). The old email parser broke a folded Main-Class.
  • Dag source. The Gradle plugin packs the main class's .java file, or airflowBundle.dagSource, into every bundle JAR, fat or thin, and names it in the manifest. get_source_code returns it, up to 1 MiB, or a placeholder. A JAR embeds one source for all its Dags, so the Java importer ignores the Dag id.

The Java runtime is unchanged here. The Java SDK layer above makes it answer the parse request, with a payload that passes validate_serialized_dag.

[sdk]
coordinators = {
  "java-native": {
    "classpath": "airflow.sdk.coordinators.java.JavaCoordinator",
    "kwargs": {"java_executable": "/usr/lib/jvm/java-17-openjdk/bin/java"}
  }
}
queue_to_coordinator = {"java-native": "java-native"}
airflowBundle {
    mainClass = "com.example.Main"
    dagSource = file("src/main/java/com/example/MyDag.java")  // optional
}

Example bundle manifest (./gradlew bundle in java-sdk/example):

Manifest-Version: 1.0
Airflow-Java-SDK-Dag-Code: META-INF/airflow/dag-code/org/apache/airflow/
 example/ExampleBundleBuilder.java
Airflow-Supervisor-Schema-Version: 2026-10-30
Main-Class: org.apache.airflow.example.ExampleBundleBuilder
Multi-Release: true

Deviations and limitations

Verification

  • task-sdk/tests/task_sdk/coordinators/java: 88 passed. Java SDK ./gradlew test at this layer passed.
  • The Maven snippet added to the docs was not built.

Was generative AI tooling used to co-author this PR?

@boring-cyborg boring-cyborg Bot added area:coordinator Coordinator: The interface to spawn Lang-SDK subprocesses area:java-sdk area:task-sdk kind:documentation labels Sep 28, 2026
@jason810496
jason810496 added this pull request to stack #73848 September 28, 2026 13:20
@jason810496 jason810496 changed the title jason/lang sdk e2e/04 java dag importer Parse native Java Dags and show their source Sep 28, 2026
@jason810496
jason810496 force-pushed the jason/lang-sdk-e2e/04-java-dag-importer branch from 4619343 to a80facc Compare September 28, 2026 15:57
@jason810496
jason810496 force-pushed the jason/lang-sdk-e2e/03-native-dag-parse branch from 6242f83 to 8e8c982 Compare September 28, 2026 15:57
@jason810496
jason810496 force-pushed the jason/lang-sdk-e2e/04-java-dag-importer branch from a80facc to d62246f Compare September 29, 2026 01:25
@jason810496
jason810496 force-pushed the jason/lang-sdk-e2e/03-native-dag-parse branch from 8e8c982 to 0080efb Compare September 29, 2026 01:26
@jason810496
jason810496 force-pushed the jason/lang-sdk-e2e/04-java-dag-importer branch from d62246f to f8acd1d Compare September 29, 2026 01:29
@jason810496
jason810496 force-pushed the jason/lang-sdk-e2e/03-native-dag-parse branch from 0080efb to c4b3431 Compare September 29, 2026 01:29
@jason810496
jason810496 removed this pull request from stack #73848 October 1, 2026 03:02
@jason810496
jason810496 force-pushed the jason/lang-sdk-e2e/03-native-dag-parse branch from c4b3431 to e6de2df Compare October 1, 2026 03:03
@jason810496
jason810496 force-pushed the jason/lang-sdk-e2e/04-java-dag-importer branch from f8acd1d to ceb6b6a Compare October 1, 2026 03:03
@jason810496
jason810496 added this pull request to stack #74005 October 1, 2026 03:04
@jason810496
jason810496 force-pushed the jason/lang-sdk-e2e/03-native-dag-parse branch from e6de2df to ec6f22e Compare October 1, 2026 06:20
@jason810496
jason810496 force-pushed the jason/lang-sdk-e2e/04-java-dag-importer branch from ceb6b6a to ca832b6 Compare October 1, 2026 06:20
@jason810496
jason810496 force-pushed the jason/lang-sdk-e2e/03-native-dag-parse branch from ec6f22e to c35472f Compare October 1, 2026 12:41
@jason810496
jason810496 force-pushed the jason/lang-sdk-e2e/04-java-dag-importer branch from ca832b6 to 5e8a705 Compare October 1, 2026 12:41
@jason810496
jason810496 removed this pull request from stack #74005 October 1, 2026 13:18
@jason810496
jason810496 force-pushed the jason/lang-sdk-e2e/04-java-dag-importer branch from 5e8a705 to 8ffd19e Compare October 1, 2026 13:18
@jason810496
jason810496 force-pushed the jason/lang-sdk-e2e/03-native-dag-parse branch from c35472f to 6f91c3e Compare October 1, 2026 13:18
Base automatically changed from jason/lang-sdk-e2e/03-native-dag-parse to jason/lang-sdk-e2e/02-importer-registry October 1, 2026 13:18
@jason810496
jason810496 merged commit 8ffd19e into jason/lang-sdk-e2e/02-importer-registry Oct 1, 2026
@jason810496
jason810496 deleted the jason/lang-sdk-e2e/04-java-dag-importer branch October 1, 2026 13:18
@jason810496
jason810496 restored the jason/lang-sdk-e2e/04-java-dag-importer branch October 1, 2026 13:36
@jason810496

Copy link
Copy Markdown
Member Author

Replaced by #74036. GitHub marked this PR as merged into a stack branch when the stack was reordered; nothing was merged into main.

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

Labels

area:coordinator Coordinator: The interface to spawn Lang-SDK subprocesses area:java-sdk area:task-sdk kind:documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant