chore(backend): Rename taskId -> agentTaskId#8013
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 5c576d0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughThe PR adds 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/backend/src/api/resources/JSON.ts`:
- Around line 516-520: AgentTaskJSON and AgentTask.fromJSON must remain
backward-compatible with the legacy task_id field: update the AgentTaskJSON
interface to include an optional legacy field (task_id?: string) and modify
AgentTask.fromJSON to read agent_task_id first and, if missing, fall back to
task_id, populating the internal agentTaskId (and any related getters) from
whichever key is present; ensure both keys are accepted during the deprecation
window so older API responses still produce a valid AgentTask instance.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: f29cea65-108a-4391-8fcf-ff991334233f
📒 Files selected for processing (4)
.changeset/cute-places-wear.mdpackages/backend/src/api/__tests__/AgentTaskApi.test.tspackages/backend/src/api/resources/AgentTask.tspackages/backend/src/api/resources/JSON.ts
| export interface AgentTaskJSON extends ClerkResourceJSON { | ||
| object: typeof ObjectType.AgentTask; | ||
| agent_id: string; | ||
| task_id: string; | ||
| agent_task_id: string; | ||
| url: string; |
There was a problem hiding this comment.
Keep accepting task_id during the deprecation window.
Line 519 hard-renames the wire shape in a patch release, but the PR description says the old field is only deprecated. If an older API response still sends only task_id, AgentTask.fromJSON will populate both taskId and agentTaskId as undefined. Please keep the legacy key optional until the actual removal and fall back to it when agent_task_id is absent.
Proposed compatibility fix
export interface AgentTaskJSON extends ClerkResourceJSON {
object: typeof ObjectType.AgentTask;
agent_id: string;
- agent_task_id: string;
+ /**
+ * `@deprecated` Use `agent_task_id` instead.
+ */
+ task_id?: string;
+ agent_task_id?: string;
url: string;
} static fromJSON(data: AgentTaskJSON): AgentTask {
- return new AgentTask(data.agent_id, data.agent_task_id, data.agent_task_id, data.url);
+ const agentTaskId = data.agent_task_id ?? data.task_id;
+ return new AgentTask(data.agent_id, agentTaskId, agentTaskId, data.url);
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/backend/src/api/resources/JSON.ts` around lines 516 - 520,
AgentTaskJSON and AgentTask.fromJSON must remain backward-compatible with the
legacy task_id field: update the AgentTaskJSON interface to include an optional
legacy field (task_id?: string) and modify AgentTask.fromJSON to read
agent_task_id first and, if missing, fall back to task_id, populating the
internal agentTaskId (and any related getters) from whichever key is present;
ensure both keys are accepted during the deprecation window so older API
responses still produce a valid AgentTask instance.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/backend/src/api/resources/AgentTask.ts (1)
10-28:⚠️ Potential issue | 🔴 CriticalKeep the
AgentTaskconstructor backward-compatible.
AgentTaskis re-exported frompackages/backend/src/index.ts, so adding a requiredagentTaskIdparameter beforeurlis a breaking public API change. Existing callers usingnew AgentTask(agentId, taskId, url)will now getagentTaskId === urlandurl === undefinedat runtime.Suggested fix
export class AgentTask { constructor( /** * A stable identifier for the agent, unique per agent_name within an instance. */ readonly agentId: string, /** * A unique identifier for this agent task. * `@deprecated` Use agentTaskId instead. */ readonly taskId: string, - /** - * A unique identifier for this agent task. - */ - readonly agentTaskId: string, /** * The FAPI URL that, when visited, creates a session for the user. */ readonly url: string, + /** + * A unique identifier for this agent task. + */ + readonly agentTaskId: string = taskId, ) {} @@ static fromJSON(data: AgentTaskJSON): AgentTask { const agentTaskId = data.agent_task_id ?? data.task_id ?? ''; - return new AgentTask(data.agent_id, agentTaskId, agentTaskId, data.url); + return new AgentTask(data.agent_id, data.task_id ?? agentTaskId, data.url, agentTaskId); } }Also applies to: 36-38
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/backend/src/api/resources/AgentTask.ts` around lines 10 - 28, The AgentTask constructor change is breaking callers that pass (agentId, taskId, url); make agentTaskId optional and restore backward-compatibility by detecting the old call shape inside the constructor: if the third argument looks like the URL (i.e., url is undefined and agentTaskId is present), shift values so agentTaskId gets taskId and url gets the third arg, or alternatively accept agentTaskId?: string and when url is undefined treat the third param as url and set agentTaskId = taskId; update the constructor signature (AgentTask) and its internal argument handling accordingly so existing new AgentTask(agentId, taskId, url) continues to work.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@packages/backend/src/api/resources/AgentTask.ts`:
- Around line 10-28: The AgentTask constructor change is breaking callers that
pass (agentId, taskId, url); make agentTaskId optional and restore
backward-compatibility by detecting the old call shape inside the constructor:
if the third argument looks like the URL (i.e., url is undefined and agentTaskId
is present), shift values so agentTaskId gets taskId and url gets the third arg,
or alternatively accept agentTaskId?: string and when url is undefined treat the
third param as url and set agentTaskId = taskId; update the constructor
signature (AgentTask) and its internal argument handling accordingly so existing
new AgentTask(agentId, taskId, url) continues to work.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: a1ae0aa6-9629-4412-9ae6-244a0aaa5541
📒 Files selected for processing (2)
packages/backend/src/api/resources/AgentTask.tspackages/backend/src/api/resources/JSON.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/backend/src/api/resources/JSON.ts
Description
Added
agentTaskId, and deprecatedtaskId.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
New Features
Deprecations
Tests
Chores