From 0f3da11bc43d7cc3432d6ac25bb295c141d909a0 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 24 Jun 2025 23:32:22 +0200 Subject: [PATCH] fix: show 404 on task detail page when the task does not exist (#1014) --- frontend/cypress/e2e/task/task.spec.ts | 6 ++++++ frontend/src/views/tasks/TaskDetailView.vue | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/frontend/cypress/e2e/task/task.spec.ts b/frontend/cypress/e2e/task/task.spec.ts index 49abc9a2b..9a90471dd 100644 --- a/frontend/cypress/e2e/task/task.spec.ts +++ b/frontend/cypress/e2e/task/task.spec.ts @@ -189,7 +189,13 @@ describe('Task', () => { LabelTaskFactory.truncate() TaskAttachmentFactory.truncate() }) + it('Shows a 404 page for nonexisting tasks', () => { + cy.visit('/tasks/9999') + + cy.contains('Not found') + .should('be.visible') + }) it('Shows all task details', () => { const tasks = TaskFactory.create(1, { id: 1, diff --git a/frontend/src/views/tasks/TaskDetailView.vue b/frontend/src/views/tasks/TaskDetailView.vue index b319c8d11..1783e8d0e 100644 --- a/frontend/src/views/tasks/TaskDetailView.vue +++ b/frontend/src/views/tasks/TaskDetailView.vue @@ -743,6 +743,13 @@ watch( attachmentStore.set(task.value.attachments) taskColor.value = task.value.hexColor setActiveFields() + } catch (e) { + if (e?.response?.status === 404) { + router.replace({name: 'not-found'}) + return + } + + throw e } finally { await nextTick() scrollToHeading()