jason810496 commented on code in PR #71188:
URL: https://github.com/apache/airflow/pull/71188#discussion_r4080958322


##########
java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/internal/ArgValues.kt:
##########
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+@file:Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
+
+package org.apache.airflow.sdk.internal
+
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.databind.json.JsonMapper
+import org.apache.airflow.sdk.Client
+import org.apache.airflow.sdk.MissingXComException
+import org.apache.airflow.sdk.TaskInput
+import org.apache.airflow.sdk.execution.ArgBinding
+import java.lang.reflect.Field
+import java.lang.reflect.Type
+
+/**
+ * @suppress
+ *
+ * Resolves a task's data parameters from the arg bindings the supervisor
+ * delivered, and decodes their raw wire values into the declared types. Public
+ * so that processor-generated task classes can call it; not user-facing API.
+ *
+ * The bindings come from the Python `@task.stub` call site, which is also the
+ * graph the scheduler ordered the run by. Flat data parameters resolve the
+ * binding at their position (through [TaskArgs]); [TaskInput] fields resolve
+ * bindings by name.
+ */
+object ArgValues {
+  private val mapper: ObjectMapper = 
JsonMapper.builder().build().findAndRegisterModules()
+
+  /**
+   * Materializes a [TaskInput] with every field bound by the argument name it
+   * claims.
+   *
+   * The single populator behind both authoring APIs — the annotation processor
+   * emits a call to it for a `@Builder.Task` [TaskInput] parameter, and
+   * [org.apache.airflow.sdk.InputTask] calls it before handing the input to a
+   * task written against the interface.
+   *
+   * @throws IllegalArgumentException if the input cannot be populated.
+   * @throws MissingXComException if a primitive field's binding resolves to
+   *    nothing.
+   */
+  @JvmStatic
+  fun <I : TaskInput> bindInput(
+    client: Client,
+    type: Class<I>,
+  ): I {
+    val input = newInput(type)
+    val arguments = ArgIndex(client.argBindings)
+    bindableFields(type).forEach { field -> field.set(input, 
resolveField(client, arguments, field)) }

Review Comment:
   Thanks for pointing this out.
   
   There're actual four cases, and here's the correct semantic:
   1. positional-based injection and SDK side miss arguments from the other 
side -> fail
   2. struct-base injection and SDK side miss arguments from the other side -> 
warning, don't fail
   3. positional-based injection and SDK side get more arguments from the other 
side -> fail
   2. struct-base injection and SDK side more arguments from the other side -> 
warning, don't fail
   
   I added the warning on current PR and I will follow-up to fix the Go and TS 
side semantic.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to