{"record":{"id":"3f8b6ccc2d751aef","repo":"wavetermdev/waveterm","slug":"error-statting-term-file-w","errorCode":null,"errorMessage":"error statting term file: %w","messagePattern":"error statting term file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshrpc/wshserver/wshserver.go","lineNumber":848,"sourceCode":"\t\tWorkspaceId: workspaceId,\n\t\tBlock:       blockData,\n\t\tFiles:       fileInfoList,\n\t}, nil\n}\n\nfunc (ws *WshServer) DebugTermCommand(ctx context.Context, data wshrpc.CommandDebugTermData) (*wshrpc.CommandDebugTermRtnData, error) {\n\tif data.BlockId == \"\" {\n\t\treturn nil, fmt.Errorf(\"blockid is required\")\n\t}\n\tif data.Size <= 0 {\n\t\treturn nil, fmt.Errorf(\"size must be greater than 0\")\n\t}\n\twaveFile, err := filestore.WFS.Stat(ctx, data.BlockId, wavebase.BlockFile_Term)\n\tif err == fs.ErrNotExist {\n\t\treturn &wshrpc.CommandDebugTermRtnData{}, nil\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error statting term file: %w\", err)\n\t}\n\treadSize := data.Size\n\tdataLength := waveFile.DataLength()\n\tif readSize > dataLength {\n\t\treadSize = dataLength\n\t}\n\treadOffset := waveFile.Size - readSize\n\treadOffset, readData, err := filestore.WFS.ReadAt(ctx, data.BlockId, wavebase.BlockFile_Term, readOffset, readSize)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading term file: %w\", err)\n\t}\n\treturn &wshrpc.CommandDebugTermRtnData{\n\t\tOffset: readOffset,\n\t\tData64: base64.StdEncoding.EncodeToString(readData),\n\t}, nil\n}\n\nfunc (ws *WshServer) WaveInfoCommand(ctx context.Context) (*wshrpc.WaveInfoData, error) {","sourceCodeStart":830,"sourceCodeEnd":866,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshrpc/wshserver/wshserver.go#L830-L866","documentation":"After validating arguments, DebugTermCommand calls filestore.WFS.Stat on the block's term file. Any stat error other than fs.ErrNotExist is wrapped as 'error statting term file' and returned, so the caller sees the underlying storage failure.","triggerScenarios":"WFS.Stat on the block's BlockFile_Term fails with a non-not-exist error: storage backend failure, permission problem, corrupted metadata for the block.","commonSituations":"Block was deleted between ID acquisition and the call leaving stale state; filestore (ZSVR domain storage) permissions changed; underlying database/storage errors.","solutions":["Inspect the wrapped %w cause to identify the storage failure","Verify the block ID is valid and the block still exists (note ErrNotExist is handled as empty result, so this error implies a deeper failure)","Check filestore/storage permissions and health for the block domain"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Optionally verify block exists first\n_, err := wcore.GetBlock(ctx, data.BlockId)\nif err != nil {\n    return fmt.Errorf(\"block not found: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"resp, err := client.DebugTermCommand(ctx, data)\nif err != nil {\n    var rootErr error\n    errors.As(err, &rootErr) // unwrap 'error statting term file' cause\n    return fmt.Errorf(\"term stat failed: %w\", err)\n}","preventionTips":["Check block validity before RPC","Monitor filestore/storage health","Use errors.As/Is on the wrapped cause for precise handling"],"tags":["filestore","storage","rpc","wrapped-error"],"backgroundTag":"file-stat-failure","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}