Skip to content

fix: guard against undefined currentProject in sidebar decoration provider - #939

Open
wahajahmed010 wants to merge 1 commit into
alefragnani:masterfrom
wahajahmed010:fix/938-sidebar-decoration-npe
Open

fix: guard against undefined currentProject in sidebar decoration provider#939
wahajahmed010 wants to merge 1 commit into
alefragnani:masterfrom
wahajahmed010:fix/938-sidebar-decoration-npe

Conversation

@wahajahmed010

Copy link
Copy Markdown

Description

Fixes a crash in the sidebar decoration provider when Container.currentProject is undefined.

Root cause: Container._currentProject is declared but never initialized, so it remains undefined whenever no saved project matches the currently open folder (e.g. a window opened on a folder not in the Project Manager list, or during startup before the current project is resolved). The provideFileDecoration method in decoration.ts accessed .rootPath on Container.currentProject without a null guard, throwing:

TypeError: Cannot read properties of undefined (reading 'rootPath')

Because provideFileDecoration is invoked repeatedly (once per tree item), the errors flood the Extension Host and can cause it to terminate.

Fix: Added a truthiness check for Container.currentProject before accessing .rootPath.

Changes

  • src/sidebar/decoration.ts: Guard Container.currentProject with a null check before accessing .rootPath

Testing

  • Compiles without new errors (pre-existing type errors in other files are unrelated)
  • Logic verified: when currentProject is undefined, the function returns undefined (no decoration), which is the correct fallback behavior

Closes #938


This contribution was created with assistance from an AI coding agent (Buck/OpenClaw). The fix was reviewed and validated for correctness.

…vider

Container.currentProject can be undefined when no saved project matches
the currently open folder (e.g. a window opened on a folder not in the
Project Manager list, or during startup before the current project is
resolved). Accessing .rootPath on undefined throws a TypeError that
floods the Extension Host and can cause it to terminate.

Closes alefragnani#938
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] - Extension Host crash: "Cannot read properties of undefined (reading 'rootPath')" in side bar decoration provider when no current project is set

1 participant