{"record":{"id":"1e2aa70d56845b31","repo":"wavetermdev/waveterm","slug":"error-finding-window-for-tab-w","errorCode":null,"errorMessage":"error finding window for tab: %w","messagePattern":"error finding window for tab: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshrpc/wshserver/wshserver.go","lineNumber":817,"sourceCode":"\t\tCreatedTs: wf.CreatedTs,\n\t\tSize:      wf.Size,\n\t\tModTs:     wf.ModTs,\n\t\tMeta:      wf.Meta,\n\t}\n}\n\nfunc (ws *WshServer) BlockInfoCommand(ctx context.Context, blockId string) (*wshrpc.BlockInfoData, error) {\n\tblockData, err := wstore.DBMustGet[*waveobj.Block](ctx, blockId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting block: %w\", err)\n\t}\n\ttabId, err := wstore.DBFindTabForBlockId(ctx, blockId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error finding tab for block: %w\", err)\n\t}\n\tworkspaceId, err := wstore.DBFindWorkspaceForTabId(ctx, tabId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error finding window for tab: %w\", err)\n\t}\n\tfileList, err := filestore.WFS.ListFiles(ctx, blockId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing blockfiles: %w\", err)\n\t}\n\tvar fileInfoList []*wshrpc.WaveFileInfo\n\tfor _, wf := range fileList {\n\t\tfileInfoList = append(fileInfoList, waveFileToWaveFileInfo(wf))\n\t}\n\treturn &wshrpc.BlockInfoData{\n\t\tBlockId:     blockId,\n\t\tTabId:       tabId,\n\t\tWorkspaceId: workspaceId,\n\t\tBlock:       blockData,\n\t\tFiles:       fileInfoList,\n\t}, nil\n}\n","sourceCodeStart":799,"sourceCodeEnd":835,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshrpc/wshserver/wshserver.go#L799-L835","documentation":"BlockInfoCommand walks up the hierarchy: block -> tab -> workspace (labeled 'window' in this message, for historical reasons). This error wraps failure of wstore.DBFindWorkspaceForTabId — the tab exists but no workspace containing it could be found or the lookup errored. It indicates a broken tab-to-workspace link.","triggerScenarios":"Calling BlockInfoCommand where data's tabId has no parent workspace: orphaned tab record after workspace deletion, workspace id corruption, or a store lookup failure.","commonSituations":"Workspace deleted while tabs from it still referenced; migration/restore of store data missing the workspace entry; concurrent workspace removal racing the command.","solutions":["Reload workspace state to rebuild the tab->workspace mapping and retry.","If the tab is orphaned, close/remove it or reassign it to an existing workspace.","Inspect the wrapped cause to separate NotFound from a genuine DB error.","Re-run after store consistency is restored (restart app or repair store)."],"exampleFix":"// before\ninfo, err := wshclient.BlockInfoCommand(ctx, blockId, nil) // workspace gone\n// after\nif _, err := wshclient.BlockInfoCommand(ctx, blockId, nil); err != nil {\n    workspaceId = ensureTabInWorkspace(currentTabId, defaultWorkspaceId) // reattach tab first\n}\n_ = workspaceId","handlingStrategy":"fallback","validationCode":"wsId := getWorkspaceIdForTabFromLocalState(tabId)\nif wsId == \"\" {\n    return errors.New(\"tab has no workspace; refusing BlockInfoCommand\")\n}","typeGuard":"func isOrphanedTab(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"error finding window for tab\")\n}","tryCatchPattern":"info, err := wshclient.BlockInfoCommand(ctx, blockId, nil)\nif err != nil && isOrphanedTab(err) {\n    // reattach tab to a default workspace, then retry\n    _ = wshclient.SetTabWorkspace(ctx, tabId, defaultWsId, nil)\n    info, err = wshclient.BlockInfoCommand(ctx, blockId, nil)\n}","preventionTips":["Remove tabs with their workspace atomically","Reload workspace state after restore/migration","Keep tab->workspace links verified on app start","Handle the 'window' naming: this step resolves the workspace"],"tags":["store","workspace","tab"],"backgroundTag":"orphaned-tab","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}