🐛 Guard workspace-page* when file-id is not a uuid (#10655)

The workspace route can be reached without a `:file-id` query parameter
(e.g. `/#/workspace?team-id=...`). When that happened, `workspace*` was
emitting `dw/initialize-workspace` with a nil file-id, which stored nil
in `:current-file-id`. The `fetch-profiles` event then read nil from
state and called `:get-profiles-for-file-comments` with `{:file-id
nil}`, producing a 400 response.

Move the `use-equal-memo` calls for `file-id` and `page-id` from
`workspace*` up to `workspace-page*`, and guard the render with
`(when (uuid? file-id) ...)` so `workspace*` only mounts when `file-id`
is a valid uuid. Since `workspace*` never mounts with a nil `file-id`,
`initialize-workspace` is never emitted with nil, and the 400 is
prevented at the source.

AI-assisted-by: minimax-m3
This commit is contained in:
Andrey Antukh 2026-07-22 09:00:43 +02:00 committed by GitHub
parent 64026fc1f6
commit 73bfc0dc15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -196,10 +196,7 @@
{::mf/wrap [mf/memo]}
[{:keys [team-id project-id file-id page-id layout-name]}]
(let [file-id (hooks/use-equal-memo file-id)
page-id (hooks/use-equal-memo page-id)
layout (mf/deref refs/workspace-layout)
(let [layout (mf/deref refs/workspace-layout)
wglobal (mf/deref refs/workspace-global)
team-ref (mf/with-memo [team-id]
@ -287,6 +284,12 @@
(mf/defc workspace-page*
{::mf/lazy-load true}
[props]
[:> workspace* props])
[{:keys [file-id page-id] :as props}]
(let [file-id (hooks/use-equal-memo file-id)
page-id (hooks/use-equal-memo page-id)
props (mf/spread-props props {:file-id file-id
:page-id page-id})]
(when (uuid? file-id)
[:> workspace* props])))