guan404ming commented on code in PR #77230:
URL: https://github.com/apache/airflow/pull/77230#discussion_r4704192822
##########
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:
Moved the check into `encodeRequest` so every request is checked and the
error names its type
##########
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:
Added the `@throws` to `setXCom` and `toPlainJson` now throws `TypeError`
##########
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:
Added `Set` and class instance cases, now in `frames.test.ts` beside the
check
--
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]