{"record":{"id":"3df158407c3ac6b0","repo":"wavetermdev/waveterm","slug":"failed-to-read-app-file-w","errorCode":null,"errorMessage":"failed to read app file: %w","messagePattern":"failed to read app file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshrpc/wshserver/wshserver.go","lineNumber":1016,"sourceCode":"\t\tEntries:      entries,\n\t\tEntryCount:   result.EntryCount,\n\t\tTotalEntries: result.TotalEntries,\n\t\tTruncated:    result.Truncated,\n\t}, nil\n}\n\nfunc (ws *WshServer) ReadAppFileCommand(ctx context.Context, data wshrpc.CommandReadAppFileData) (*wshrpc.CommandReadAppFileRtnData, error) {\n\tif data.AppId == \"\" {\n\t\treturn nil, fmt.Errorf(\"must provide an appId to ReadAppFileCommand\")\n\t}\n\tfileData, err := waveappstore.ReadAppFile(data.AppId, data.FileName)\n\tif err != nil {\n\t\tif errors.Is(err, os.ErrNotExist) {\n\t\t\treturn &wshrpc.CommandReadAppFileRtnData{\n\t\t\t\tNotFound: true,\n\t\t\t}, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"failed to read app file: %w\", err)\n\t}\n\treturn &wshrpc.CommandReadAppFileRtnData{\n\t\tData64: base64.StdEncoding.EncodeToString(fileData.Contents),\n\t\tModTs:  fileData.ModTs,\n\t}, nil\n}\n\nfunc (ws *WshServer) WriteAppFileCommand(ctx context.Context, data wshrpc.CommandWriteAppFileData) error {\n\tif data.AppId == \"\" {\n\t\treturn fmt.Errorf(\"must provide an appId to WriteAppFileCommand\")\n\t}\n\tcontents, err := base64.StdEncoding.DecodeString(data.Data64)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to decode data64: %w\", err)\n\t}\n\treturn waveappstore.WriteAppFile(data.AppId, data.FileName, contents)\n}\n","sourceCodeStart":998,"sourceCodeEnd":1034,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshrpc/wshserver/wshserver.go#L998-L1034","documentation":"ReadAppFileCommand wraps any read error that is not os.ErrNotExist as 'failed to read app file'. Missing files are handled gracefully (NotFound: true), so this error indicates a genuine read failure in the app store.","triggerScenarios":"waveappstore.ReadAppFile fails with a non-ErrNotExist error: permission denied on the app storage file, IO failure, or app storage corruption.","commonSituations":"Filesystem permissions on the wave app store directory; disk errors; app file locked or unreadable.","solutions":["Inspect the wrapped underlying error for the exact cause","Check read permissions on the app storage directory/file","Verify disk health / free space and retry","Confirm the app store path (wave home) is accessible to the process"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure app storage is readable beforehand\nif _, err := os.Stat(appStorageDir); err != nil {\n    return fmt.Errorf(\"app storage inaccessible: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"file, err := client.ReadAppFileCommand(ctx, data)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to read app file\") {\n        var cause error\n        errors.As(err, &cause)\n        // check permissions/IO and retry\n    }\n    return err\n}","preventionTips":["Check permissions on the wave app store directory","Use errors.As to inspect the wrapped cause","Treat os.ErrNotExist separately (returned as NotFound, not this error)"],"tags":["appstore","filesystem","io-error","wrapped-error"],"backgroundTag":"file-read-failure","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}