{"record":{"id":"e39af318b16816dc","repo":"wavetermdev/waveterm","slug":"error-opening-path-w","errorCode":null,"errorMessage":"error opening path: %w","messagePattern":"error opening path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshrpc/wshserver/wshserver.go","lineNumber":1443,"sourceCode":"\t}\n\n\tif openInternal && openExternal {\n\t\treturn \"\", fmt.Errorf(\"open and openExternal cannot both be true\")\n\t}\n\n\tif openInternal {\n\t\t_, err := ws.CreateBlockCommand(ctx, wshrpc.CommandCreateBlockData{\n\t\t\tTabId: data.TabId,\n\t\t\tBlockDef: &waveobj.BlockDef{Meta: map[string]any{\n\t\t\t\twaveobj.MetaKey_View: \"preview\",\n\t\t\t\twaveobj.MetaKey_File: path,\n\t\t\t}},\n\t\t\tEphemeral: true,\n\t\t\tFocused:   true,\n\t\t})\n\n\t\tif err != nil {\n\t\t\treturn path, fmt.Errorf(\"error opening path: %w\", err)\n\t\t}\n\t} else if openExternal {\n\t\terr := open.Run(path)\n\t\tif err != nil {\n\t\t\treturn path, fmt.Errorf(\"error opening path: %w\", err)\n\t\t}\n\t}\n\treturn path, nil\n}\n\nfunc (ws *WshServer) FetchSuggestionsCommand(ctx context.Context, data wshrpc.FetchSuggestionsData) (*wshrpc.FetchSuggestionsResponse, error) {\n\treturn suggestion.FetchSuggestions(ctx, data)\n}\n\nfunc (ws *WshServer) DisposeSuggestionsCommand(ctx context.Context, widgetId string) error {\n\tsuggestion.DisposeSuggestions(ctx, widgetId)\n\treturn nil\n}","sourceCodeStart":1425,"sourceCodeEnd":1461,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshrpc/wshserver/wshserver.go#L1425-L1461","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Inspect the wrapped cause (%w) for the real failure — usually an invalid or stale TabId.","Call GetTabCommand with the TabId first to confirm the tab exists.","Re-run the command so a fresh/current TabId is used, or omit TabId if the client supports resolving the current tab."],"exampleFix":"// before\n_, err := wshclient.PathCommand(ctx, wshrpc.PathCommandData{PathType: \"data\", Open: true, TabId: staleTabId})\n// after\ntab, err := wshclient.GetTabCommand(ctx, currentTabId)\nif err == nil {\n    _, err = wshclient.PathCommand(ctx, wshrpc.PathCommandData{PathType: \"data\", Open: true, TabId: currentTabId})\n}","handlingStrategy":"try-catch","validationCode":"tab, err := wshclient.GetTabCommand(ctx, tabId)\nif err != nil {\n    return fmt.Errorf(\"tab %s not available: %w\", tabId, err)\n}","typeGuard":null,"tryCatchPattern":"_, err := wshclient.PathCommand(ctx, data)\nif err != nil && strings.Contains(err.Error(), \"error opening path\") {\n    log.Printf(\"internal open failed for %s: %v; falling back to returning path only\", data.PathType, err)\n}","preventionTips":["Always resolve a fresh TabId immediately before the call; never cache tab ids across sessions.","Prefer omitting Open when you only need the path string.","Handle the returned path even on error — PathCommand returns it alongside the failure."],"tags":["rpc","blocks","waveterm"],"backgroundTag":"invalid-block-target","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}