This repository was archived by the owner on Aug 6, 2026. It is now read-only.
fix(task-detail): guard against undefined task in TaskDetail render - #3774
Closed
posthog[bot] wants to merge 2 commits into
Closed
fix(task-detail): guard against undefined task in TaskDetail render#3774posthog[bot] wants to merge 2 commits into
posthog[bot] wants to merge 2 commits into
Conversation
useRefreshedTask could return undefined when another observer subscribed to the same query key without initialData and created the cache entry first while the fetch was in flight, causing React Query to drop this hook's initialData. That undefined flowed into getTaskRepository, which dereferenced task.repository unguarded and threw inside React's render loop, crashing the whole TaskDetail view. Restore the pre-regression guarantee that useTaskData always has a defined task by returning `data ?? initialTask`, and make getTaskRepository null-safe on its argument as defense in depth. Generated-By: PostHog Code Task-Id: 400e2a89-4ede-447f-8ce9-97f61889cd19
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
tatoalo
marked this pull request as ready for review
July 24, 2026 08:18
tatoalo
enabled auto-merge (squash)
July 24, 2026 08:23
auto-merge was automatically disabled
July 29, 2026 10:56
Pull request was closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Opening a task in the Code app could hard-crash the whole TaskDetail view with
Cannot read properties of undefined (reading 'repository'), thrown inside React's render loop.useRefreshedTask(added in #3758) returned its querydataas if it were always aTask. But the route components subscribe to the same query key withoutinitialData; when their observer creates the cache entry first while the fetch is still in flight, React Query dropsuseRefreshedTask'sinitialDataanddatacomes backundefined. Thatundefinedflowed straight intogetTaskRepository, which dereferencedtask.repositorywith no guard and threw during render.This is a same-day regression from #3758 on a core flow (opening a task).
Changes
useRefreshedTasknow returnsdata ?? initialTask, restoring the pre-regression guarantee thatuseTaskDataalways receives a defined task.getTaskRepositoryis now null-safe on itstaskargument as defense in depth.How did you test this?
useRefreshedTask.test.tsxasserting the hook falls back toinitialTaskwhen the query yieldsundefineddata.repository.test.tscoveringgetTaskRepositorywithundefined/null/ missing / populated inputs (plusparseRepository).pnpm --filter @posthog/ui typecheckandpnpm --filter @posthog/shared typecheck(clean) and Biome lint on the changed files.Automatic notifications
Created with PostHog Code from this inbox report.