uranusjr commented on code in PR #77230:
URL: https://github.com/apache/airflow/pull/77230#discussion_r4692220822
##########
ts-sdk/tests/coordinator/client.test.ts:
##########
@@ -295,6 +295,20 @@ describe("getXComEntry", () => {
});
});
+describe("setXCom value guard", () => {
+ it.each([
+ ["a Date", { fetchedAt: new Date(0) }],
+ ["a Buffer", [Buffer.from("abc")]],
+ ["a Map", new Map([["a", 1]])],
+ ])("rejects a value holding %s without sending a request", async
(description, value) => {
Review Comment:
This should also test the class instance and Set cases.
##########
ts-sdk/src/sdk/client.ts:
##########
@@ -173,6 +173,8 @@ export interface TaskStateStore {
* negative, NaN, or Infinity; when the deployment's
* `[state_store] default_retention_days` is invalid; or when the resolved
* expiry would overflow the wire timestamp (year 9999).
+ * @throws `Error` when `value` holds something JSON cannot carry, such as a
+ * `Date` or a `Buffer`.
Review Comment:
The `setXCom` docs need the same `@throws`; the check applies there too but
isn't documented.
Also, this probably should throws TypeError instead. This would require a
change in `plain-json.ts` too.
##########
ts-sdk/src/coordinator/client.ts:
##########
@@ -304,7 +305,7 @@ export function createCoordinatorClient(
type: "SetTaskStateStore",
ti_id: tiId,
key,
- value,
+ value: toPlainJson(value, `task state store value for "${key}"`),
Review Comment:
Is there a better way to do this? Applying this at call time makes it easy
to miss request types. It’s probably a better idea to put the check inside
`encodeRequest` so all request data are checked by default.
--
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]