Skip to content
Closed
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
6 changes: 5 additions & 1 deletion packages/trigger-sdk/src/v3/envvars.ts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Pre-existing bug in the task-context branch assigns slug to projectRef

When taskContext.ctx is truthy and slugOrParams is a string (the 5-arg overload path), line 308 sets $projectRef = slugOrParams instead of $projectRef = projectRefOrName. This means the slug value gets used as the project reference. Line 309 then sets $slug = slugOrParams ?? taskContext.ctx.environment.slug which is correct in value but the ?? is dead code since slugOrParams is already confirmed to be a string (and thus truthy) by the typeof check on line 307.

This means that calling envvars.update("proj_ref", "dev", "MY_VAR", { value: "x" }) from inside a task context would send the API request with projectRef="dev" and slug="dev" instead of projectRef="proj_ref" and slug="dev". The PR fixes the analogous issue in the else branch but leaves this bug untouched.

(Refers to lines 308-309)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Missing changeset for public package modification

The AGENTS.md requires adding a changeset when modifying any public package (packages/*). This PR modifies packages/trigger-sdk/src/v3/envvars.ts but the .changeset/ directory only contains README.md and config.json (no changeset file). This should be added before merge per repository conventions.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,17 @@ export function update(
throw new Error("projectRef is required");
}

if (typeof nameOrRequestOptions !== "string") {
throw new Error("name is required");
}

if (!params) {
throw new Error("params is required");
}

$projectRef = projectRefOrName;
$slug = slugOrParams;
$name = name!;
$name = nameOrRequestOptions;
$params = params;
}

Expand Down
7 changes: 7 additions & 0 deletions packages/trigger-sdk/src/v3/triggerClient.types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ describe("TriggerClient surface — type-level guarantees", () => {
// Zero-arg form (uses task context — still typeable at the call site)
expectTypeOf(client.envvars.list).toBeCallableWith();
});

it("preserves envvars.update overloads (out of task context form AND in-task form)", () => {
// Four-arg form (out-of-task context: projectRef, slug, name, params)
expectTypeOf(client.envvars.update).toBeCallableWith("proj_1234", "dev", "MY_VAR", { value: "secret" });
// Two-arg form (in-task context: name, params)
expectTypeOf(client.envvars.update).toBeCallableWith("MY_VAR", { value: "secret" });
});
});

describe("TriggerClient surface — curated subsets", () => {
Expand Down