fix(trpc): default agent to 'claude' in createAutomationSchema for SDK <alpha.10 compat#4552
fix(trpc): default agent to 'claude' in createAutomationSchema for SDK <alpha.10 compat#4552sazabi[bot] wants to merge 1 commit into
Conversation
…K <alpha.10 compat SDK <alpha.10 and any caller predating PR #4481 omit the `agent` field (previously `agentConfig`) and receive a ZodError BAD_REQUEST. Adding `.default('claude')` makes the field optional-on-wire while keeping it required in the DB — matching the pre-rename behaviour where claude was effectively the implicit default. 17 BAD_REQUEST errors observed in production since 2026-05-13 12:32 UTC. Relates to #4481.
|
Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews. |
Greptile SummaryThis PR applies a targeted backwards-compatibility fix for the
Confidence Score: 5/5Safe to merge — single-field schema change with no DB impact and a valid, bounded default value. The change is a one-line addition of No files require special attention.
|
| Filename | Overview |
|---|---|
| packages/trpc/src/router/automation/schema.ts | Adds .default("claude") to the agent field in createAutomationSchema so SDK <alpha.10 / CLI <0.2.16 callers that omit the field are silently defaulted instead of receiving a Zod validation error. |
Sequence Diagram
sequenceDiagram
participant OldCaller as SDK <alpha.10 / CLI <0.2.16
participant NewCaller as SDK ≥alpha.10 / CLI ≥0.2.16
participant tRPC as tRPC automation.create
participant Zod as createAutomationSchema
participant DB as Database
OldCaller->>tRPC: "{ name, prompt } (agent: undefined)"
tRPC->>Zod: "parse({ name, prompt })"
Note over Zod: agent: agentSchema.default("claude")<br/>undefined → "claude"
Zod-->>tRPC: "{ name, prompt, agent: "claude" }"
tRPC->>DB: "INSERT agent = "claude""
NewCaller->>tRPC: "{ name, prompt, agent: "claude-opus-4" }"
tRPC->>Zod: "parse({ name, prompt, agent: "claude-opus-4" })"
Zod-->>tRPC: "{ name, prompt, agent: "claude-opus-4" }"
tRPC->>DB: "INSERT agent = "claude-opus-4""
Reviews (1): Last reviewed commit: "fix(trpc): default agent to 'claude' in ..." | Re-trigger Greptile
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Problem
SDK <alpha.10 and callers predating PR #4481 omit the
agentfield (previouslyagentConfig) fromautomation.createrequests. Since #4481 deployed theagent text not nullDB column and strict Zod schema, these callers receive aBAD_REQUEST ZodError: Invalid input: expected string, received undefinedon theagentpath.17 errors observed in production since 2026-05-13 12:32 UTC.
The error pattern:
Fix
Add
.default("claude")to theagentfield increateAutomationSchema. This makes the field optional on the wire (matching SDK <alpha.10 / CLI <0.2.16 behaviour) while the stored value remains a non-null string — identical to the pre-rename implicit default.No changes to the DB schema or any other callers.
Testing
!!selectedAgentbefore submit — unaffectedagent— unaffectedagent— unaffected"claude"instead of erroringRelates to #4481.
Summary by cubic
Default
agentto "claude" increateAutomationSchemato restore compatibility with older clients that omit the field. This prevents Zod BAD_REQUEST errors onautomation.createwhile keeping the DB value non-null.agentdefault viaagentSchema.default("claude").Written for commit d1199a9. Summary will update on new commits.