{"record":{"id":"5974e15d391bdb32","repo":"wavetermdev/waveterm","slug":"error-finding-tab-v","errorCode":null,"errorMessage":"error finding tab: %v","messagePattern":"error finding tab: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshrpc/wshserver/resolvers.go","lineNumber":93,"sourceCode":"\t\treturn \"uuid8\", simpleId, nil\n\t}\n\n\treturn \"\", \"\", fmt.Errorf(\"invalid simple id format: %s\", simpleId)\n}\n\n// Individual resolvers\nfunc resolveThis(ctx context.Context, data wshrpc.CommandResolveIdsData, value string) (*waveobj.ORef, error) {\n\tif data.BlockId == \"\" {\n\t\treturn nil, fmt.Errorf(\"no blockid in request\")\n\t}\n\n\tif value == SimpleId_This || value == SimpleId_Block {\n\t\treturn &waveobj.ORef{OType: waveobj.OType_Block, OID: data.BlockId}, nil\n\t}\n\tif value == SimpleId_Tab {\n\t\ttabId, err := wstore.DBFindTabForBlockId(ctx, data.BlockId)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error finding tab: %v\", err)\n\t\t}\n\t\treturn &waveobj.ORef{OType: waveobj.OType_Tab, OID: tabId}, nil\n\t}\n\tif value == SimpleId_Ws || value == SimpleId_Workspace {\n\t\ttabId, err := wstore.DBFindTabForBlockId(ctx, data.BlockId)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error finding tab: %v\", err)\n\t\t}\n\t\twsId, err := wstore.DBFindWorkspaceForTabId(ctx, tabId)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error finding workspace: %v\", err)\n\t\t}\n\t\treturn &waveobj.ORef{OType: waveobj.OType_Workspace, OID: wsId}, nil\n\t}\n\tif value == SimpleId_Client || value == SimpleId_Global {\n\t\tclientId := wstore.GetClientId()\n\t\treturn &waveobj.ORef{OType: waveobj.OType_Client, OID: clientId}, nil\n\t}","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshrpc/wshserver/resolvers.go#L75-L111","documentation":"When resolving the 'tab' simple id, resolveThis finds the tab that contains the request's block via wstore.DBFindTabForBlockId. This error wraps a failure of that lookup — the tab containing the given blockId could not be found or the store lookup errored. It indicates an inconsistent block reference or store access problem.","triggerScenarios":"Calling ResolveIds with simpleId 'tab' where data.BlockId refers to a block that no longer exists, was deleted concurrently, or the wstore lookup returns an error (record missing / DB failure).","commonSituations":"Stale frontend state after a block was closed; resolving ids for blocks in a tab that was just removed; race between block deletion and id resolution; corrupted or out-of-sync local store.","solutions":["Verify the blockId still exists (BlockInfoCommand or store lookup) before resolving 'tab'.","Refresh workspace/tab state on the client and retry with a current blockId.","Handle NotFound distinctly and fall back to resolving via the workspace's tab list."],"exampleFix":"// before\noref, err := wshclient.ResolveIdsCommand(ctx, wshrpc.CommandResolveIdsData{SimpleId: \"tab\", BlockId: staleBlockId}, nil)\n// after\nif _, err := wshclient.BlockInfoCommand(ctx, staleBlockId, nil); err != nil {\n    staleBlockId = currentBlockId // refresh from view state\n}\noref, err := wshclient.ResolveIdsCommand(ctx, wshrpc.CommandResolveIdsData{SimpleId: \"tab\", BlockId: staleBlockId}, nil)","handlingStrategy":"validation","validationCode":"_, err := wshclient.BlockInfoCommand(ctx, blockId, nil)\nif err != nil {\n    return fmt.Errorf(\"block %s gone, cannot resolve 'tab': %w\", blockId, err)\n}","typeGuard":"func isNotFound(err error) bool {\n    return err != nil && (errors.Is(err, wstore.ErrNotFound) || strings.Contains(err.Error(), \"not found\"))\n}","tryCatchPattern":"tabRef, err := wshclient.ResolveIdsCommand(ctx, wshrpc.CommandResolveIdsData{SimpleId: \"tab\", BlockId: blockId}, nil)\nif err != nil && isNotFound(err) {\n    tabRef = resolveTabFromCurrentWorkspace(blockId) // fallback path\n}","preventionTips":["Refresh local block references after tab/block deletions","Subscribe to workspace change events to drop stale block ids","Resolve 'tab' only for live, currently mounted blocks","Handle NotFound distinctly from generic errors"],"tags":["resolver","store","block"],"backgroundTag":"block-not-found","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}