wavetermdev/waveterm · error

error opening path: %w

Error message

error opening path: %w

What it means

PathCommand was asked to open the resolved path internally (Open=true), which creates an ephemeral focused 'preview' block in the given tab via CreateBlockCommand. When that block creation fails, the error is wrapped as "error opening path". It is a wrapped error: the underlying cause (from the block controller) is the real diagnostic.

Source

Thrown at pkg/wshrpc/wshserver/wshserver.go:1443

	}

	if openInternal && openExternal {
		return "", fmt.Errorf("open and openExternal cannot both be true")
	}

	if openInternal {
		_, err := ws.CreateBlockCommand(ctx, wshrpc.CommandCreateBlockData{
			TabId: data.TabId,
			BlockDef: &waveobj.BlockDef{Meta: map[string]any{
				waveobj.MetaKey_View: "preview",
				waveobj.MetaKey_File: path,
			}},
			Ephemeral: true,
			Focused:   true,
		})

		if err != nil {
			return path, fmt.Errorf("error opening path: %w", err)
		}
	} else if openExternal {
		err := open.Run(path)
		if err != nil {
			return path, fmt.Errorf("error opening path: %w", err)
		}
	}
	return path, nil
}

func (ws *WshServer) FetchSuggestionsCommand(ctx context.Context, data wshrpc.FetchSuggestionsData) (*wshrpc.FetchSuggestionsResponse, error) {
	return suggestion.FetchSuggestions(ctx, data)
}

func (ws *WshServer) DisposeSuggestionsCommand(ctx context.Context, widgetId string) error {
	suggestion.DisposeSuggestions(ctx, widgetId)
	return nil
}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Inspect the wrapped cause (%w) for the real failure — usually an invalid or stale TabId.
  2. Call GetTabCommand with the TabId first to confirm the tab exists.
  3. Re-run the command so a fresh/current TabId is used, or omit TabId if the client supports resolving the current tab.

Example fix

// before
_, err := wshclient.PathCommand(ctx, wshrpc.PathCommandData{PathType: "data", Open: true, TabId: staleTabId})
// after
tab, err := wshclient.GetTabCommand(ctx, currentTabId)
if err == nil {
    _, err = wshclient.PathCommand(ctx, wshrpc.PathCommandData{PathType: "data", Open: true, TabId: currentTabId})
}
Defensive patterns

Strategy: try-catch

Validate before calling

tab, err := wshclient.GetTabCommand(ctx, tabId)
if err != nil {
    return fmt.Errorf("tab %s not available: %w", tabId, err)
}

Try / catch

_, err := wshclient.PathCommand(ctx, data)
if err != nil && strings.Contains(err.Error(), "error opening path") {
    log.Printf("internal open failed for %s: %v; falling back to returning path only", data.PathType, err)
}

Prevention

When it happens

Trigger: PathCommandData.Open=true with a TabId that does not exist, has been closed, or where the block subsystem refuses to create a preview block (e.g. invalid BlockDef metadata or an inaccessible wave store).

Common situations: Stale TabId captured before a tab was closed; running `wsh path --open` against a connection whose window/tab state changed; block registry failures on the client side.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/e39af318b16816dc. Report an issue: GitHub.