{"record":{"id":"979c5f5b00e8f92d","repo":"wavetermdev/waveterm","slug":"must-provide-an-appid-to-readappfilecommand","errorCode":null,"errorMessage":"must provide an appId to ReadAppFileCommand","messagePattern":"must provide an appId to ReadAppFileCommand","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshrpc/wshserver/wshserver.go","lineNumber":1007,"sourceCode":"\t\t\tMode:         entry.Mode,\n\t\t\tModified:     entry.Modified,\n\t\t\tModifiedTime: entry.ModifiedTime,\n\t\t}\n\t}\n\treturn &wshrpc.CommandListAllAppFilesRtnData{\n\t\tPath:         result.Path,\n\t\tAbsolutePath: result.AbsolutePath,\n\t\tParentDir:    result.ParentDir,\n\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 == \"\" {","sourceCodeStart":989,"sourceCodeEnd":1025,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshrpc/wshserver/wshserver.go#L989-L1025","documentation":"Returned when ReadAppFileCommand is invoked without an appId; the request is invalid because reads are scoped per app.","triggerScenarios":"Calling ReadAppFileCommand with CommandReadAppFileData.AppId == \"\".","commonSituations":"AppId lost when building the request; using a default-constructed data struct; client code reading a file before resolving the app.","solutions":["Set AppId to a valid editable-app ID (from ListAllEditableAppsCommand)","Ensure the field is populated and serialized in the RPC request","Validate inputs in the calling code before dispatching the RPC"],"exampleFix":"// before\nf, err := client.ReadAppFileCommand(ctx, wshrpc.CommandReadAppFileData{FileName: \"main.ts\"})\n// after\nf, err := client.ReadAppFileCommand(ctx, wshrpc.CommandReadAppFileData{AppId: appId, FileName: \"main.ts\"})","handlingStrategy":"validation","validationCode":"if data.AppId == \"\" {\n    return fmt.Errorf(\"cannot call ReadAppFileCommand: AppId is empty\")\n}","typeGuard":"func hasAppId(data wshrpc.CommandReadAppFileData) bool {\n    return data.AppId != \"\"\n}","tryCatchPattern":"file, err := client.ReadAppFileCommand(ctx, data)\nif err != nil {\n    if strings.Contains(err.Error(), \"must provide an appId\") {\n        // fix payload: set AppId\n    }\n    return err\n}\nif file.NotFound {\n    // missing file handled via NotFound flag, not an error\n}","preventionTips":["Set AppId from a validated app list","Check the NotFound response field instead of treating missing files as errors","Validate required fields client-side"],"tags":["validation","rpc","appstore","missing-parameter"],"backgroundTag":"missing-required-argument","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}