You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "FrankYang0529 (via GitHub)" <gi...@apache.org> on 2026/07/03 09:23:25 UTC
Re: [PR] Java SDK: Throw MissingXComException instead of NPE for absent XComs [airflow]
FrankYang0529 commented on code in PR #69257:
URL: https://github.com/apache/airflow/pull/69257#discussion_r3518873165
##########
java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/Client.kt:
##########
@@ -153,3 +153,25 @@ class Client internal constructor(
mapIndex = details.ti.mapIndex ?: -1,
)
}
+
+/**
+ * Thrown when a task parameter with a primitive type reads an XCom that was never pushed.
+ */
+class MissingXComException(
+ message: String,
+) : IllegalStateException(message) {
+ companion object {
+ @JvmStatic
+ fun requireXCom(
+ value: Any?,
+ taskId: String,
+ paramName: String,
+ ): Any =
+ value
+ ?: throw MissingXComException(
+ "Task parameter '$paramName' requires an XCom from task '$taskId', but none was pushed. " +
+ "This parameter has a primitive type that cannot be null; declare it with a boxed type " +
+ "(e.g. Integer instead of int) to receive null.",
+ )
+ }
Review Comment:
I removed the static method and changed to use if to check null in BuilderProcessor.
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org