[PR #12590] fix(tui): prevent path type error crash when plugins return objects #14284

Open
opened 2026-02-16 18:19:05 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12590

State: open
Merged: No


Fixes #12589 - adds coerceFsPath utility that safely handles various path-like input shapes (objects, URLs, arrays) before calling Node.js path functions.

I've fixed this issue. The root cause was that normalizePath in session/index.tsx called path.isAbsolute(input) without validating that input was a string. When plugins like opencode-antigravity-auth@latest returned objects (e.g., { path: string }) instead of raw strings, Node.js threw the TypeError.

Fix: Added a coerceFsPath utility that safely handles various path-like input shapes (objects, URLs, arrays) before calling Node.js path functions.

Branch: fix-path-type-12589

Changes:

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12590 **State:** open **Merged:** No --- Fixes #12589 - adds coerceFsPath utility that safely handles various path-like input shapes (objects, URLs, arrays) before calling Node.js path functions. I've fixed this issue. The root cause was that [normalizePath](cci:1://file:///Users/venom/opencode/packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx:21:0-38:1) in [session/index.tsx](cci:7://file:///Users/venom/opencode/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx:0:0-0:0) called `path.isAbsolute(input)` without validating that [input](cci:1://file:///Users/venom/opencode/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx:1406:4-1408:5) was a string. When plugins like `opencode-antigravity-auth@latest` returned objects (e.g., `{ path: string }`) instead of raw strings, Node.js threw the TypeError. **Fix:** Added a [coerceFsPath](cci:1://file:///Users/venom/opencode/packages/opencode/src/util/coerce-path.ts:2:0-83:1) utility that safely handles various path-like input shapes (objects, URLs, arrays) before calling Node.js path functions. **Branch:** `fix-path-type-12589` **Changes:** - New: [src/util/coerce-path.ts](cci:7://file:///Users/venom/opencode/packages/opencode/src/util/coerce-path.ts:0:0-0:0) - Safe type coercion utility - New: [test/util/coerce-path.test.ts](cci:7://file:///Users/venom/opencode/packages/opencode/test/util/coerce-path.test.ts:0:0-0:0) - Unit tests - Updated: [session/index.tsx](cci:7://file:///Users/venom/opencode/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx:0:0-0:0) and [session/permission.tsx](cci:7://file:///Users/venom/opencode/packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx:0:0-0:0) to use the utility
yindo added the pull-request label 2026-02-16 18:19:05 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14284