Skip to content

Commit d00af71

Browse files
committed
fix: preserve empty task payloads and validation messages
1 parent c05c5ca commit d00af71

5 files changed

Lines changed: 21 additions & 4 deletions

File tree

apps/webapp/app/routes/account._index/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function createSchema(
9292
name: z
9393
.string({ error: "You must enter a name" })
9494
.min(2, "Your name must be at least 2 characters long")
95-
.max(50),
95+
.max(50, "Your name must be 50 characters or less"),
9696
email: emailSchema.pipe(
9797
z.string().superRefine((email, ctx) => {
9898
if (constraints.isEmailUnique === undefined) {

apps/webapp/app/routes/account.tokens/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const CreateTokenSchema = z.discriminatedUnion("action", [
170170
tokenName: z
171171
.string({ error: "You must enter a name" })
172172
.min(2, "Your name must be at least 2 characters long")
173-
.max(50),
173+
.max(50, "Your name must be 50 characters or less"),
174174
// Optional — when no RBAC plugin is installed the UI hides the
175175
// dropdown and submits no roleId; the action passes that through
176176
// and createPersonalAccessToken just doesn't write a TokenRole.

packages/core/src/v3/schemas/api-type.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ describe("InitializeDeploymentRequestBody", () => {
141141
});
142142

143143
describe("TriggerTaskRequestBody", () => {
144+
it("accepts a missing payload", () => {
145+
const result = TriggerTaskRequestBody.safeParse({
146+
options: {},
147+
});
148+
149+
expect(result.success).toBe(true);
150+
});
151+
144152
it("accepts application/store payload as a non-empty string", () => {
145153
const result = TriggerTaskRequestBody.safeParse({
146154
payload: "packets/payloads/file.json",

packages/core/src/v3/schemas/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ const ConcurrencyKeySchema = z.union([z.string(), z.number()]).transform((value)
202202

203203
export const TriggerTaskRequestBody = z
204204
.object({
205-
payload: z.any(),
205+
payload: z.any().optional(),
206206
context: z.any().optional(),
207207
options: z
208208
.object({
@@ -312,7 +312,7 @@ export type BatchTriggerTaskRequestBody = z.infer<typeof BatchTriggerTaskRequest
312312

313313
export const BatchTriggerTaskItem = z.object({
314314
task: z.string(),
315-
payload: z.any(),
315+
payload: z.any().optional(),
316316
context: z.any().optional(),
317317
options: z
318318
.object({

packages/core/src/v3/schemas/batchItemNDJSON.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ describe("concurrencyKey coercion", () => {
5858
});
5959

6060
describe("BatchTriggerTaskItem", () => {
61+
it("accepts a missing payload", () => {
62+
const result = BatchTriggerTaskItem.safeParse({
63+
task: "user-workflow-tick",
64+
options: {},
65+
});
66+
67+
expect(result.success).toBe(true);
68+
});
69+
6170
it("coerces a numeric concurrencyKey to a string", () => {
6271
const result = BatchTriggerTaskItem.safeParse({
6372
task: "user-workflow-tick",

0 commit comments

Comments
 (0)