TypeError: null is not an object (evaluating 'share.url') breaks vibe-kanban integration #2108

Open
opened 2026-02-16 17:34:11 -05:00 by yindo · 1 comment
Owner

Originally created by @smart-tinker on GitHub (Oct 14, 2025).

Originally assigned to: @rekram1-node on GitHub.

Problem Description

When using OpenCode with vibe-kanban, a TypeError occurs that completely breaks the integration:

ERROR 2025-10-14T15:45:10 +4053ms service=default name=TypeError 
message=null is not an object (evaluating 'share2.url') 
stack=TypeError: null is not an object (evaluating 'share2.url')

This error makes the vibe-kanban integration completely non-functional because vibe-kanban relies entirely on the share bridge mechanism to receive all data from OpenCode (AI messages, tool calls, thinking blocks).

Root Cause Analysis

The issue occurs because OpenCode attempts to access share.url without null/undefined checks in multiple locations. The share field in Session.Info is defined as optional (packages/opencode/src/session/index.ts:36-40), but the code doesn't consistently handle cases where it might be null or undefined.

Affected Code Locations

1. TUI Share Command (packages/tui/internal/tui/tui.go:1215-1224)

The code directly accesses response.Share.URL without checking if response.Share is nil.

2. Automatic Session Sharing (packages/opencode/src/session/index.ts:124-132)

When share: "auto" is configured, the sharing process runs asynchronously and errors are silently caught with catch(() => {}), leaving the share field undefined.

Why This Happens

The error can occur in several scenarios:

  1. Async timing issue: The sharing process hasn't completed yet when code tries to access share.url
  2. Silent failure: Sharing fails but the error is caught and ignored, leaving share undefined
  3. Pre-existing sessions: Sessions created before enabling auto-share don't have the share field populated
  4. Network issues: HTTP request to share bridge fails

Impact on vibe-kanban Integration

According to vibe-kanban's architecture:

  • vibe-kanban runs a local HTTP server (share bridge) on a random port
  • OpenCode connects to it via the OPENCODE_API environment variable
  • OpenCode sends events to /share_sync endpoint
  • vibe-kanban receives ALL data through this share bridge mechanism (not through stdout/stderr)

When sharing fails, vibe-kanban only receives stderr error logs but no actual working data (AI responses, tool calls, thinking blocks), making the integration completely broken.

Proposed Solution

Add null/undefined checks before accessing share.url in all locations:

For Go Code (TUI)

// In packages/tui/internal/tui/tui.go
if response.Share != nil && response.Share.URL != "" {
    shareUrl := response.Share.URL
    // ... use shareUrl safely
} else {
    // Handle the case where share is not available
    // Either show an error or skip share-related operations
}

For TypeScript Code

// In packages/opencode/src/session/index.ts
// Instead of silently catching errors:
Session.share(session.id, { secret: session.secret })
  .then((share) => {
    if (share?.url) {
      // Use share.url safely
    }
  })
  .catch((error) => {
    // Log the error properly instead of ignoring it
    console.error("Failed to create share:", error);
  });

// When accessing share.url elsewhere:
if (session.share?.url) {
  const url = session.share.url;
  // ... use url
}

Additional Improvements

  1. Better error handling: Don't silently ignore sharing errors with empty catch(() => {})
  2. Proper logging: Log when sharing fails so users can diagnose issues
  3. Graceful degradation: Allow OpenCode to continue working even if sharing fails
  4. Type safety: Ensure TypeScript types properly reflect that share is optional

Reproduction Steps

  1. Set up vibe-kanban integration with OpenCode
  2. Configure OpenCode with share: "auto" or set OPENCODE_AUTO_SHARE=1 environment variable
  3. Create a new session
  4. Observe the TypeError in stderr output
  5. Notice that vibe-kanban shows only error messages, no actual AI responses

Environment

  • OpenCode version: 0.15.2
  • vibe-kanban version: 0.0.107
  • Operating System: Linux devvm 6.14.0-33-generic 33~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 19 17:02:30 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
  • Node.js version: v22.16.0

Additional Context

The share field is defined as optional in the schema (packages/opencode/src/session/index.ts:36-40):

This means any code working with sessions must account for the possibility of this field being absent.

References

  • Share sync implementation: packages/opencode/src/share/share.ts:27-35
  • Session creation with auto-share: packages/opencode/src/session/index.ts:124-133
  • TUI share command: packages/tui/internal/tui/tui.go:1215-1224

Notes

This issue description provides:

  • Clear problem statement with error details
  • Root cause analysis with specific code locations and citations
  • Explanation of why this breaks vibe-kanban integration
  • Concrete, implementable solutions for both Go and TypeScript code
  • Reproduction steps
  • Context about why the field is optional

The detailed code references and proposed solutions should make it easier for maintainers to understand and fix the issue quickly.

PS: made with DeepWiki help

Originally created by @smart-tinker on GitHub (Oct 14, 2025). Originally assigned to: @rekram1-node on GitHub. ## Problem Description When using OpenCode with vibe-kanban, a `TypeError` occurs that completely breaks the integration: ``` ERROR 2025-10-14T15:45:10 +4053ms service=default name=TypeError message=null is not an object (evaluating 'share2.url') stack=TypeError: null is not an object (evaluating 'share2.url') ``` This error makes the vibe-kanban integration completely non-functional because vibe-kanban relies entirely on the share bridge mechanism to receive all data from OpenCode (AI messages, tool calls, thinking blocks).<cite/> ## Root Cause Analysis The issue occurs because OpenCode attempts to access `share.url` without null/undefined checks in multiple locations. The `share` field in `Session.Info` is defined as optional (packages/opencode/src/session/index.ts:36-40), but the code doesn't consistently handle cases where it might be null or undefined.<cite/> ### Affected Code Locations **1. TUI Share Command (packages/tui/internal/tui/tui.go:1215-1224)** The code directly accesses `response.Share.URL` without checking if `response.Share` is nil.<cite/> **2. Automatic Session Sharing (packages/opencode/src/session/index.ts:124-132)** When `share: "auto"` is configured, the sharing process runs asynchronously and errors are silently caught with `catch(() => {})`, leaving the `share` field undefined.<cite/> ## Why This Happens The error can occur in several scenarios: 1. **Async timing issue**: The sharing process hasn't completed yet when code tries to access `share.url`<cite/> 2. **Silent failure**: Sharing fails but the error is caught and ignored, leaving `share` undefined<cite/> 3. **Pre-existing sessions**: Sessions created before enabling auto-share don't have the `share` field populated<cite/> 4. **Network issues**: HTTP request to share bridge fails<cite/> ## Impact on vibe-kanban Integration According to vibe-kanban's architecture: - vibe-kanban runs a local HTTP server (share bridge) on a random port - OpenCode connects to it via the `OPENCODE_API` environment variable - OpenCode sends events to `/share_sync` endpoint - vibe-kanban receives ALL data through this share bridge mechanism (not through stdout/stderr) When sharing fails, vibe-kanban only receives stderr error logs but no actual working data (AI responses, tool calls, thinking blocks), making the integration completely broken.<cite/> ## Proposed Solution Add null/undefined checks before accessing `share.url` in all locations: ### For Go Code (TUI) ```go // In packages/tui/internal/tui/tui.go if response.Share != nil && response.Share.URL != "" { shareUrl := response.Share.URL // ... use shareUrl safely } else { // Handle the case where share is not available // Either show an error or skip share-related operations } ``` ### For TypeScript Code ```typescript // In packages/opencode/src/session/index.ts // Instead of silently catching errors: Session.share(session.id, { secret: session.secret }) .then((share) => { if (share?.url) { // Use share.url safely } }) .catch((error) => { // Log the error properly instead of ignoring it console.error("Failed to create share:", error); }); // When accessing share.url elsewhere: if (session.share?.url) { const url = session.share.url; // ... use url } ``` ### Additional Improvements 1. **Better error handling**: Don't silently ignore sharing errors with empty `catch(() => {})`<cite/> 2. **Proper logging**: Log when sharing fails so users can diagnose issues 3. **Graceful degradation**: Allow OpenCode to continue working even if sharing fails 4. **Type safety**: Ensure TypeScript types properly reflect that `share` is optional ## Reproduction Steps 1. Set up vibe-kanban integration with OpenCode 2. Configure OpenCode with `share: "auto"` or set `OPENCODE_AUTO_SHARE=1` environment variable 3. Create a new session 4. Observe the TypeError in stderr output 5. Notice that vibe-kanban shows only error messages, no actual AI responses ## Environment - OpenCode version: 0.15.2 - vibe-kanban version: 0.0.107 - Operating System: Linux devvm 6.14.0-33-generic 33~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 19 17:02:30 UTC 2 x86_64 x86_64 x86_64 GNU/Linux - Node.js version: v22.16.0 ## Additional Context The `share` field is defined as optional in the schema (packages/opencode/src/session/index.ts:36-40):<cite/> This means any code working with sessions must account for the possibility of this field being absent.<cite/> ## References - Share sync implementation: packages/opencode/src/share/share.ts:27-35 - Session creation with auto-share: packages/opencode/src/session/index.ts:124-133 - TUI share command: packages/tui/internal/tui/tui.go:1215-1224 --- ## Notes This issue description provides:<cite/> - Clear problem statement with error details - Root cause analysis with specific code locations and citations - Explanation of why this breaks vibe-kanban integration - Concrete, implementable solutions for both Go and TypeScript code - Reproduction steps - Context about why the field is optional The detailed code references and proposed solutions should make it easier for maintainers to understand and fix the issue quickly.<cite/> PS: made with DeepWiki help
Author
Owner

@rekram1-node commented on GitHub (Oct 14, 2025):

hmm ill take a look

@rekram1-node commented on GitHub (Oct 14, 2025): hmm ill take a look
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2108