Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(api): keep a new required field from stopping a repeating series

olozano-f2bafb169286
diff --git a/apps/api/src/task/controllers/duplicate-task.ts b/apps/api/src/task/controllers/duplicate-task.ts
index 645c74a26..a5ff78cf0 100644
--- a/apps/api/src/task/controllers/duplicate-task.ts
+++ b/apps/api/src/task/controllers/duplicate-task.ts
@@ -224,8 +224,9 @@ async function duplicateTask({
fieldId,
value: value ?? "",
}));
- // Older tasks may predate a required field. Apply its current default or fail
- // validation, just as creation does, before copying anything in storage.
+ // Older tasks may predate a required field. Apply its current default, then
+ // fail validation as creation does before copying anything in storage. An
+ // occurrence leaves the field empty instead, so the series keeps going.
for (const definition of fieldDefinitions) {
if (!definition.required || !definition.defaultValue?.trim()) continue;
const existing = customFields.find(
@@ -239,7 +240,8 @@ async function duplicateTask({
else if (!existing.value.trim())
existing.value = definition.defaultValue.trim();
}
- await assertRequiredCustomFields(sourceTask.projectId, customFields);
+ if (!occurrence)
+ await assertRequiredCustomFields(sourceTask.projectId, customFields);
const sourceLabels = await db
.select({
diff --git a/apps/api/src/task/recurrence/subscribe.ts b/apps/api/src/task/recurrence/subscribe.ts
index 07c89b9a6..be3cc56b4 100644
--- a/apps/api/src/task/recurrence/subscribe.ts
+++ b/apps/api/src/task/recurrence/subscribe.ts
@@ -9,7 +9,12 @@ subscribeToEvent<{ taskId: string; userId?: string | null }>(
// Leave the completing request's context so task.created reaches its own
// window too: that client may have refetched the board before this insert.
await eventContext.exit(() =>
- createNextOccurrence(data.taskId, data.userId),
+ createNextOccurrence(data.taskId, data.userId).catch((error) => {
+ console.error(
+ `Failed to create the next occurrence of task ${data.taskId}`,
+ error,
+ );
+ }),
);
},
);
diff --git a/tests/api-integration/task-recurrence.test.ts b/tests/api-integration/task-recurrence.test.ts
index 5d87046d5..57cb2880a 100644
--- a/tests/api-integration/task-recurrence.test.ts
+++ b/tests/api-integration/task-recurrence.test.ts
@@ -432,6 +432,28 @@ describe("API integration: recurring tasks", () => {
).toHaveLength(0);
});
+ it("keeps repeating when a required field has no value", async () => {
+ const { project, columns } = await seedProject();
+ const task = await seedTask(project.id, columns.done.id, {
+ status: "done",
+ });
+ // Added after the task, without a default to fill it.
+ await db.insert(schema.customFieldDefinitionTable).values({
+ projectId: project.id,
+ name: "Audience",
+ type: "text",
+ required: true,
+ });
+
+ const next = await createNextOccurrence(task.id, null);
+
+ expect(next).toMatchObject({
+ status: "to-do",
+ dueDate: new Date("2026-03-17T00:00:00.000Z"),
+ recurrence: weekly,
+ });
+ });
+
it("tells clients that the completed task no longer repeats", async () => {
const { project, columns } = await seedProject();
const task = await seedTask(project.id, columns.done.id, {