Skip to content

Commit 80bbfef

Browse files
1stvampTrigger.dev RepoOps
authored andcommitted
fix(supervisor): stop the runner token's uid reaching the Runner spec
Mono-RevId: b882af2b96296eb4b1010903fe41af0b2b612572
1 parent 6bf731b commit 80bbfef

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

apps/supervisor/src/workloadManager/runCrd.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,33 @@ describe("runnerBodyFor carries the isolation lane it is given", () => {
5353
});
5454
});
5555

56+
/**
57+
* Asserted here because the type cannot: create() passes a variable, and
58+
* TypeScript's excess property check only applies to object literals.
59+
*/
60+
describe("runnerBodyFor sends only what the CRD declares", () => {
61+
it("takes only name and key from a wider token handle", () => {
62+
const body = runnerBodyFor(createOptions(), {
63+
...meta,
64+
token: { name: "runner-abc123-token-deadbeef", key: "token", uid: "uid-not-in-the-crd" } as {
65+
name: string;
66+
key: string;
67+
},
68+
});
69+
70+
expect(body.spec.deployment.token).toEqual({
71+
name: "runner-abc123-token-deadbeef",
72+
key: "token",
73+
});
74+
});
75+
76+
it("omits the token entirely when there is none", () => {
77+
const body = runnerBodyFor(createOptions(), meta);
78+
79+
expect(body.spec.deployment).not.toHaveProperty("token");
80+
});
81+
});
82+
5683
describe("runnerBodyFor", () => {
5784
it("names the object after the runner and carries the required spec", () => {
5885
const body = runnerBodyFor(createOptions(), meta);

apps/supervisor/src/workloadManager/runCrd.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,9 @@ export function runnerBodyFor(
296296
deployment: {
297297
friendlyID: opts.deploymentFriendlyId,
298298
version: opts.deploymentVersion,
299-
...(meta.token ? { token: meta.token } : {}),
299+
// Field by field, not spread: the handle also carries the Secret's uid,
300+
// which the spec has no field for and Strict validation rejects by name.
301+
...(meta.token ? { token: { name: meta.token.name, key: meta.token.key } } : {}),
300302
},
301303
owner: {
302304
envID: opts.envId,

0 commit comments

Comments
 (0)