Repository navigation
fix: guard .trim() calls on potentially undefined workspaceDir - #24875
Merged
Merged
Conversation
Change workspaceDir param type from string to string | undefined in resolvePluginSkillDirs and use nullish coalescing before .trim() to prevent TypeError when workspaceDir is undefined.
kevinWangSheng
approved these changes
Feb 23, 2026
kevinWangSheng
left a comment
Contributor
There was a problem hiding this comment.
Review Summary
This is a minimal, well-scoped fix for a real crash bug.
What it fixes
resolvePluginSkillDirstypedworkspaceDirasstringbut callers could passundefined, causingTypeError: Cannot read properties of undefined (reading 'trim')
Implementation quality
- ✅ Type signature now honestly reflects reality:
string | undefined - ✅ Defensive nullish coalescing:
(params.workspaceDir ?? "").trim() - ✅ No behavior change for valid inputs
- ✅ All CI checks pass (build, test, lint, Windows)
Security impact
None - this is a defensive bug fix.
Recommendation: Ready to merge
steipete
approved these changes
Feb 24, 2026
steipete
left a comment
Contributor
There was a problem hiding this comment.
Reviewed via /landpr flow. Diff scoped and checks looked good.
plgs2005
pushed a commit
to plgs2005/openclaw
that referenced
this pull request
Feb 24, 2026
…law#24875) Change workspaceDir param type from string to string | undefined in resolvePluginSkillDirs and use nullish coalescing before .trim() to prevent TypeError when workspaceDir is undefined.
12 tasks done
margulans
pushed a commit
to margulans/Neiron-AI-assistant
that referenced
this pull request
Feb 25, 2026
…law#24875) Change workspaceDir param type from string to string | undefined in resolvePluginSkillDirs and use nullish coalescing before .trim() to prevent TypeError when workspaceDir is undefined.
kevinWangSheng
pushed a commit
to kevinWangSheng/openclaw
that referenced
this pull request
Feb 26, 2026
…law#24875) Change workspaceDir param type from string to string | undefined in resolvePluginSkillDirs and use nullish coalescing before .trim() to prevent TypeError when workspaceDir is undefined.
kevinWangSheng
pushed a commit
to kevinWangSheng/openclaw
that referenced
this pull request
Feb 26, 2026
…law#24875) Change workspaceDir param type from string to string | undefined in resolvePluginSkillDirs and use nullish coalescing before .trim() to prevent TypeError when workspaceDir is undefined.
2 tasks done
mylukin
pushed a commit
to mylukin/openclaw
that referenced
this pull request
Feb 26, 2026
…law#24875) Change workspaceDir param type from string to string | undefined in resolvePluginSkillDirs and use nullish coalescing before .trim() to prevent TypeError when workspaceDir is undefined.
desertstackdev
pushed a commit
to desertstackdev/openclaw
that referenced
this pull request
Feb 28, 2026
…law#24875) Change workspaceDir param type from string to string | undefined in resolvePluginSkillDirs and use nullish coalescing before .trim() to prevent TypeError when workspaceDir is undefined.
lovewanwan
pushed a commit
to lovewanwan/openclaw
that referenced
this pull request
Apr 28, 2026
…law#24875) Change workspaceDir param type from string to string | undefined in resolvePluginSkillDirs and use nullish coalescing before .trim() to prevent TypeError when workspaceDir is undefined.
ogt-redknie
pushed a commit
to ogt-redknie/OPENX
that referenced
this pull request
May 2, 2026
…law#24875) Change workspaceDir param type from string to string | undefined in resolvePluginSkillDirs and use nullish coalescing before .trim() to prevent TypeError when workspaceDir is undefined.
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
May 9, 2026
…law#24875) Change workspaceDir param type from string to string | undefined in resolvePluginSkillDirs and use nullish coalescing before .trim() to prevent TypeError when workspaceDir is undefined.
lhfer
pushed a commit
to lhfer/openclaw
that referenced
this pull request
Oct 11, 2026
…law#24875) Change workspaceDir param type from string to string | undefined in resolvePluginSkillDirs and use nullish coalescing before .trim() to prevent TypeError when workspaceDir is undefined.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
resolvePluginSkillDirstypesworkspaceDirasstringbut callers can passundefined, causing aTypeError: Cannot read properties of undefined (reading \x27trim\x27)crash.Fix
workspaceDirparam type fromstringtostring | undefined(params.workspaceDir ?? "").trim()This is a one-line type fix + one-line runtime guard. The existing early return on empty string handles the rest.
Supersedes #12956.
Greptile Summary
Updated
resolvePluginSkillDirsto handleundefinedworkspaceDir parameter, preventing runtime crash when callers pass undefined values. Changed parameter type fromstringtostring | undefinedand added nullish coalescing operator to safely handle undefined before calling.trim().The fix correctly addresses the TypeError by:
(params.workspaceDir ?? "")to convert undefined to empty string before trimmingThis is a minimal, defensive fix that prevents crashes without changing behavior for valid inputs.
Confidence Score: 5/5
Last reviewed commit: f848180