{"record":{"id":"7b7eca22d95ca51d","repo":"wavetermdev/waveterm","slug":"error-getting-tab-w-7b7eca","errorCode":null,"errorMessage":"error getting tab: %w","messagePattern":"error getting tab: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshrpc/wshserver/wshserver.go","lineNumber":1466,"sourceCode":"\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}\n\nfunc (ws *WshServer) GetTabCommand(ctx context.Context, tabId string) (*waveobj.Tab, error) {\n\ttab, err := wstore.DBGet[*waveobj.Tab](ctx, tabId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting tab: %w\", err)\n\t}\n\treturn tab, nil\n}\n\nfunc (ws *WshServer) GetAllBadgesCommand(ctx context.Context) ([]baseds.BadgeEvent, error) {\n\treturn wcore.GetAllBadges(), nil\n}\n\nfunc (ws *WshServer) GetSecretsCommand(ctx context.Context, names []string) (map[string]string, error) {\n\tresult := make(map[string]string)\n\tfor _, name := range names {\n\t\tvalue, exists, err := secretstore.GetSecret(name)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error getting secret %q: %w\", name, err)\n\t\t}\n\t\tif exists {\n\t\t\tresult[name] = value\n\t\t}","sourceCodeStart":1448,"sourceCodeEnd":1484,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshrpc/wshserver/wshserver.go#L1448-L1484","documentation":"GetTabCommand looks up a *waveobj.Tab by id via wstore.DBGet. Any store-level failure (decode error, DB error) is wrapped as \"error getting tab\". Note that a simple missing tab id may surface here as a store error depending on wstore behavior.","triggerScenarios":"Calling GetTabCommand (wsh `gettab`) with a tabId not present in the wave store, a malformed OID, or when the underlying wstore DB read/decode fails.","commonSituations":"Automation scripts holding a tabId after the tab/window was closed; cross-connection usage where the tab id belongs to a different Wave instance; corrupted local wave DB.","solutions":["Verify the tabId with GetAllTabsCommand or list the current tabs and use a fresh id.","Check the wrapped cause to distinguish 'not found' from DB/decode errors.","If the wave DB is implicated, inspect the data dir store; restarting Wave may reload a healthy store."],"exampleFix":"// before\ntab, err := wshclient.GetTabCommand(ctx, cachedTabId)\n// after\ntabs, _ := wshclient.GetAllTabsCommand(ctx)\nif len(tabs) > 0 {\n    tab, err = wshclient.GetTabCommand(ctx, tabs[0].Oid)\n}","handlingStrategy":"validation","validationCode":"tabs, err := wshclient.GetAllTabsCommand(ctx)\nif err != nil {\n    return err\n}\nfound := false\nfor _, t := range tabs.Tabs {\n    if string(t.Oid) == tabId {\n        found = true\n        break\n    }\n}\nif !found {\n    return fmt.Errorf(\"tab %s does not exist\", tabId)\n}","typeGuard":null,"tryCatchPattern":"tab, err := wshclient.GetTabCommand(ctx, tabId)\nif err != nil && strings.Contains(err.Error(), \"error getting tab\") {\n    // refresh tab list and retry with a current id\n}","preventionTips":["Treat tab ids as ephemeral: re-fetch before each use.","Never hardcode tab ids in scripts; enumerate tabs dynamically.","Distinguish 'not found' from DB corruption by reading errors.Unwrap(err)."],"tags":["rpc","store","waveterm"],"backgroundTag":"entity-not-found","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}