{"record":{"id":"e2241dcae74d3dba","repo":"wavetermdev/waveterm","slug":"error-getting-block-w-e2241d","errorCode":null,"errorMessage":"error getting block: %w","messagePattern":"error getting block: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshrpc/wshserver/wshserver.go","lineNumber":809,"sourceCode":"\treturn shellutil.FindGitBash(&fullConfig, rescan), nil\n}\n\nfunc waveFileToWaveFileInfo(wf *filestore.WaveFile) *wshrpc.WaveFileInfo {\n\treturn &wshrpc.WaveFileInfo{\n\t\tZoneId:    wf.ZoneId,\n\t\tName:      wf.Name,\n\t\tOpts:      wf.Opts,\n\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{","sourceCodeStart":791,"sourceCodeEnd":827,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshrpc/wshserver/wshserver.go#L791-L827","documentation":"BlockInfoCommand assembles metadata for a block: its record, containing tab, workspace/window, and blockfile list. This error wraps a failure of wstore.DBMustGet[*waveobj.Block] — the given blockId does not correspond to an existing block record (or the store lookup failed). Nothing else in the command runs.","triggerScenarios":"Calling BlockInfoCommand with a blockId that was deleted, never existed, or a malformed id; the store returns NotFound or a DB error.","commonSituations":"Frontend holding a stale blockId after the block was closed; caller passing an oid of a non-block object type; race with tab/workspace removal; typos when scripting against the RPC.","solutions":["Verify the blockId exists and is a block-type oid before calling.","Refresh block references from the workspace/tab state and retry.","Handle the wrapped NotFound by cleaning up stale UI state referencing the block.","Check for type mismatches: the oid must be for a Block, not a tab/workspace."],"exampleFix":"// before\ninfo, err := wshclient.BlockInfoCommand(ctx, staleBlockId, nil)\n// after\ninfo, err := wshclient.BlockInfoCommand(ctx, currentBlockId, nil)\nif err != nil && strings.Contains(err.Error(), \"error getting block\") {\n    // remove stale block from UI state\n}","handlingStrategy":"validation","validationCode":"if blockId == \"\" {\n    return errors.New(\"blockId required\")\n}\n// ensure the oid is a block ref\nif _, err := waveobj.ParseORef(\"block:\" + blockId); err != nil {\n    return err\n}","typeGuard":"func isBlockGone(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"error getting block\")\n}","tryCatchPattern":"info, err := wshclient.BlockInfoCommand(ctx, blockId, nil)\nif err != nil {\n    if isBlockGone(err) {\n        removeStaleBlockFromState(blockId)\n        return nil\n    }\n    return err\n}","preventionTips":["Keep blockId references in sync with block-close events","Validate oids are block-type before RPC calls","Clean up UI state referencing deleted blocks","Distinguish NotFound from transient store errors"],"tags":["store","block","rpc"],"backgroundTag":"record-not-found","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}