henry3260 commented on code in PR #76893:
URL: https://github.com/apache/airflow/pull/76893#discussion_r4596254374


##########
ts-sdk/src/coordinator/client.ts:
##########
@@ -145,12 +166,22 @@ const RETENTION_DAYS_ENV_VAR = 
"AIRFLOW__STATE_STORE__DEFAULT_RETENTION_DAYS";
 const MS_PER_SECOND = 1000;
 const SECONDS_PER_DAY = 24 * 60 * 60;
 
-function assertKey(key: string): void {
+function assertKey(key: string, label = "task state store key"): void {

Review Comment:
   nit: `assertKey` is now shared, but `label` still defaults to "task state 
store key". A future caller that forgets the label would report the wrong 
thing. Would making `label` required be acceptable?



##########
ts-sdk/src/coordinator/client.ts:
##########
@@ -58,14 +58,35 @@ import type {
  */
 type AbsentRowPolicy = "throw" | { codes: readonly string[]; apiServer404: 
boolean };
 
-function resolveWireMapIndex(
-  requestedMapIndex: number | null | undefined,
-  contextMapIndex: number,
-): number | null {
-  // `mapIndex` is nullable, so only use the context value when the user did
-  // not provide one. If the user passes null, send null to the supervisor.
-  const mapIndex = requestedMapIndex === undefined ? contextMapIndex : 
requestedMapIndex;
-  return mapIndex == null || mapIndex < 0 ? null : mapIndex;
+type XComTargetOpts = Pick<GetXComOpts, "key" | "dagId" | "runId" | "taskId" | 
"mapIndex">;
+
+function resolveXComTarget(opts: XComTargetOpts, ctx: TaskContext) {
+  // The supervisor never replies to a frame with a wrongly typed field, so the
+  // task would hang instead of failing fast.
+  assertKey(opts.key, "XCom key");
+  for (const [label, id] of [
+    ["dagId", opts.dagId],
+    ["taskId", opts.taskId],
+    ["runId", opts.runId],
+  ] as const) {
+    if (id != null) assertKey(id, `XCom ${label}`);

Review Comment:
   Indeed @jason810496 PTAL



-- 
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