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


##########
ts-sdk/src/coordinator/client.ts:
##########
@@ -126,6 +139,23 @@ export function createCoordinatorClient(
       return value;
     },
 
+    async setVariable(key: string, value: string, description?: string | 
null): Promise<void> {
+      // `description` is a required wire field the supervisor validates, so it
+      // is always sent; null is what Python's `Variable.set` stores by 
default.
+      const msg: PutVariable = {
+        type: "PutVariable",
+        key,
+        value,
+        description: description ?? null,
+      };
+      await rpc("PutVariable", null, msg, () => undefined, "throw");

Review Comment:
   Why the "PutVariable" is "throw" instead of "null"?
   IIUC, the set variable operation return nothing.



##########
ts-sdk/src/coordinator/client.ts:
##########
@@ -25,12 +25,18 @@ import type { ConnectionResult, GetXComOpts, JsonValue, 
SetXComOpts } from "../s
 import { ConnectionNotFoundError, VariableNotFoundError } from 
"../sdk/client.js";
 import type {
   GetVariable,
+  PutVariable,
+  DeleteVariable,
   GetXCom,
   SetXCom,
   GetConnection,
   ConnectionResult as WireConnectionResult,
 } from "./protocol.js";
 
+/** What a supervisor "row is absent" error means for an operation: only a 
lookup
+ *  can return `null`; for a `void` call a swallowed error would read as 
success. */
+type AbsentRow = "null" | "throw";

Review Comment:
   Would `AbsentRowPolicy` or `OnAbsentRow` as naming be more clear?
   
   ```suggestion
   type AbsentRowPolicy = "null" | "throw";
   ```
   



##########
ts-sdk/src/sdk/client.ts:
##########
@@ -47,6 +47,23 @@ export interface TaskClient {
    */
   getVariableOrThrow(key: string): Promise<string>;
 
+  /**
+   * Store an Airflow Variable, replacing any existing value.
+   *
+   * The value is stored as a string. Serialize structured data (for example
+   * with `JSON.stringify`) before storing it.
+   *
+   * Omitting `description` clears the description the Variable had.
+   */
+  setVariable(key: string, value: string, description?: string | null): 
Promise<void>;
+
+  /**
+   * Delete an Airflow Variable.
+   *
+   * Rejects when the key does not exist, matching Python `Variable.delete`.
+   */

Review Comment:
   Claude found out that the Execution API didn't reject when the keuy does not 
exist, it still return 204 status code.
   
   How about rephrasing the statement as:
   ```suggestion
      * Resolves even when the key does not exist — the Execution API's delete
      * route is idempotent and does not report a missing key as an error.
   ```
   



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