fix(archive): skip updateTasks dispatch for empty updates (#7268)

Editing a recurring task schedule when no archive instances exist
dispatched TaskSharedActions.updateTasks with tasks: [], tripping the
operation-log validator with "invalid entityId/entityIds (undefined)".
Guard the batch dispatch on updates.length > 0 so the empty-array path
is a no-op for all three callers that route through updateArchiveTasks.
This commit is contained in:
Johannes Millan 2026-04-18 22:09:25 +02:00
parent 404c68127a
commit 3ed287516a
2 changed files with 16 additions and 1 deletions

View file

@ -449,6 +449,19 @@ describe('TaskArchiveService', () => {
);
});
it('should NOT dispatch when updates array is empty (issue #7268)', async () => {
archiveDbAdapterMock.loadArchiveYoung.and.returnValue(
Promise.resolve(createMockArchiveModel([])),
);
archiveDbAdapterMock.loadArchiveOld.and.returnValue(
Promise.resolve(createMockArchiveModel([])),
);
await service.updateTasks([]);
expect(storeMock.dispatch).not.toHaveBeenCalled();
});
it('should NOT dispatch actions when isSkipDispatch is true', async () => {
const task1 = createMockTask('task1', { title: 'Task 1' });
const youngArchive = createMockArchiveModel([task1]);

View file

@ -356,7 +356,9 @@ export class TaskArchiveService {
// Using updateTasks (batch) instead of individual updateTask to create
// a single operation instead of N operations. This is critical for
// repeating task config updates that affect many archived instances.
if (!options?.isSkipDispatch) {
// Skip dispatch for empty updates to avoid an invalid operation-log entry
// with entityIds: [] (see operation-log.effects.ts validator).
if (!options?.isSkipDispatch && updates.length > 0) {
this.store.dispatch(TaskSharedActions.updateTasks({ tasks: updates }));
}
}