Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ it out for a Dag that only runs when triggered. A cron schedule runs in UTC.

Every task of the Dag runs on the Node.js coordinator, so it needs a queue that
:ref:`queue_to_coordinator <typescript-sdk/coordinator-config>` sends there. Set ``queue`` once on the Dag and
each task inherits it. A task's own ``queue`` wins over the Dag's.
each task inherits it. A task's own ``queue`` wins over the Dag's. A ``queue`` that is set cannot be blank.

Order-only dependencies
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
9 changes: 9 additions & 0 deletions ts-sdk/src/sdk/dag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export interface DagSpec extends GeneratedDagFields {
* A native Dag's tasks are executed by the Node coordinator, which the
* deployment's `queue_to_coordinator` maps a queue to, so this is what
* routes them there. `queue` on a {@link TaskSpec} wins for that task.
* A `queue` that is set cannot be blank.
*/
readonly queue?: string;
}
Expand Down Expand Up @@ -1122,6 +1123,7 @@ export class Dag {
}
spec[key] = value[key];
}
rejectBlankQueue(spec["queue"], `Dag "${this.dagId}" task "${taskId}"`);
return spec as TaskSpec;
}

Expand Down Expand Up @@ -1540,6 +1542,13 @@ function validateDagSpec(dagId: string, spec: DagSpec): void {
throw new Error(`Unknown option "${String(key)}" in the spec for Dag "${dagId}"`);
}
}
rejectBlankQueue(value["queue"], `Dag "${dagId}"`);
}

function rejectBlankQueue(queue: unknown, owner: string): void {
if (typeof queue === "string" && queue.trim() === "") {
throw new Error(`queue in the spec for ${owner} must not be blank`);
}
}

/**
Expand Down
14 changes: 14 additions & 0 deletions ts-sdk/tests/sdk/dag.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,20 @@ describe("Dag", () => {
expect(dag.taskIds).toEqual([]);
});

it.each(["", " "])("rejects the blank queue %j in the Dag spec", (queue) => {
expect(() => new Dag("example_dag", { queue })).toThrowError(
'queue in the spec for Dag "example_dag" must not be blank',
);
});

it.each(["", " "])("rejects the blank queue %j in the task spec", (queue) => {
const dag = new Dag("example_dag", { queue: "typescript" });
expect(() => dag.task("transform", async () => undefined, { queue })).toThrowError(
'queue in the spec for Dag "example_dag" task "transform" must not be blank',
);
expect(dag.taskIds).toEqual([]);
});

it.each([
["null", null],
["an array", []],
Expand Down
Loading