Skip to content

handle when task path is null#1304

Merged
priosshrsth merged 3 commits into
mainfrom
anit/out-3795-typeerror-cannot-read-properties-of-null-reading-replaceall
Jun 12, 2026
Merged

handle when task path is null#1304
priosshrsth merged 3 commits into
mainfrom
anit/out-3795-typeerror-cannot-read-properties-of-null-reading-replaceall

Conversation

@priosshrsth

@priosshrsth priosshrsth commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator
  • Handle when path is null.
2026-06-11.16-54-35.mov

@priosshrsth priosshrsth self-assigned this Jun 9, 2026
@linear-code

linear-code Bot commented Jun 9, 2026

Copy link
Copy Markdown

OUT-3795

@priosshrsth priosshrsth marked this pull request as ready for review June 9, 2026 11:50
@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tasks-app Building Building Preview, Comment Jun 11, 2026 11:07am

Request Review

@greptile-apps

greptile-apps Bot commented Jun 9, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a crash in getTraversalPath when a task's ltree path column is null — a state that can occur during data migrations or for tasks created before the column was fully populated. The fix also adds a lightweight defensive guard to getIdsFromLtreePath in ltree.ts.

  • tasks.service.ts: The SQL query now selects both path and parentId; when the ltree path is absent, the traversal falls back to [parentId, id] so the caller still gets a partial (but valid) ancestor chain instead of crashing.
  • ltree.ts: getIdsFromLtreePath now coalesces a falsy path to '' before splitting, making it resilient to callers that inadvertently pass a null.
  • CLAUDE.md / docs/PUBLIC_ATTACHMENT_FLOW.md: whitespace and Markdown table alignment only.

Confidence Score: 5/5

Safe to merge — the null-path fallback is correct and the only logic change is well-scoped to getTraversalPath.

The fix is narrow: it handles a previously-unguarded null path by falling back to [parentId, id], which gives callers a valid partial ancestor chain instead of a crash. The raw query correctly selects the additional column needed for the fallback. No auth, write, or data-mutation paths are touched. The remaining changes are documentation and whitespace only.

No files require special attention.

Important Files Changed

Filename Overview
src/app/api/tasks/tasks.service.ts Core fix: adds parentId to raw query and introduces a fallback ancestor list when ltree path is null; variable shadowing in the fallback lambda is a minor style concern.
src/utils/ltree.ts Defensive `
CLAUDE.md Whitespace/blank-line formatting only; no logic changes.
docs/PUBLIC_ATTACHMENT_FLOW.md Markdown table alignment and minor formatting only; no content changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[getTraversalPath called with id] --> B[Raw SQL: SELECT path, parentId FROM Tasks WHERE id]
    B --> C{task found?}
    C -- No --> D[throw 404 NOT_FOUND]
    C -- Yes --> E[getIdsFromLtreePath task.path OR '']
    E --> F{parentIdsFromLtree.length > 0?}
    F -- Yes --> G[parentIds = ltree-derived IDs]
    F -- No --> H["parentIds = [task.parentId, id].flatMap(compact)"]
    G --> I[db.task.findMany where id in parentIds]
    H --> I
    I --> J[Build parentTasksById Map]
    J --> K[Map parentIds to tasks, throw 404 if any missing]
    K --> L[subtaskService.getAccessiblePathTasks]
    L --> M[Return AncestorTaskResponse array]
Loading

Reviews (3): Last reviewed commit: "add parent id to select statement" | Re-trigger Greptile

Comment thread src/app/api/tasks/tasks.service.ts Outdated
Comment thread src/utils/ltree.ts
@priosshrsth priosshrsth marked this pull request as draft June 9, 2026 11:59
@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Deployment failed with the following error:

Deploying Serverless Functions to multiple regions is restricted to the Pro and Enterprise plans.

Learn More: https://vercel.link/multiple-function-regions

@priosshrsth

Copy link
Copy Markdown
Collaborator Author

@greptileai review the pr again

@priosshrsth priosshrsth changed the title handle when task is null handle when task path is null Jun 11, 2026
@priosshrsth priosshrsth marked this pull request as ready for review June 11, 2026 11:12
@priosshrsth priosshrsth merged commit 11b442f into main Jun 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants