{"record":{"id":"cbca110b1db4db43","repo":"wavetermdev/waveterm","slug":"must-provide-an-appid-to-renameappfilecommand","errorCode":null,"errorMessage":"must provide an appId to RenameAppFileCommand","messagePattern":"must provide an appId to RenameAppFileCommand","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshrpc/wshserver/wshserver.go","lineNumber":1117,"sourceCode":"\terr = waveappstore.WriteAppFile(data.AppId, \"app.go\", formattedOutput)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tencoded := base64.StdEncoding.EncodeToString(formattedOutput)\n\treturn &wshrpc.CommandWriteAppGoFileRtnData{Data64: encoded}, nil\n}\n\nfunc (ws *WshServer) DeleteAppFileCommand(ctx context.Context, data wshrpc.CommandDeleteAppFileData) error {\n\tif data.AppId == \"\" {\n\t\treturn fmt.Errorf(\"must provide an appId to DeleteAppFileCommand\")\n\t}\n\treturn waveappstore.DeleteAppFile(data.AppId, data.FileName)\n}\n\nfunc (ws *WshServer) RenameAppFileCommand(ctx context.Context, data wshrpc.CommandRenameAppFileData) error {\n\tif data.AppId == \"\" {\n\t\treturn fmt.Errorf(\"must provide an appId to RenameAppFileCommand\")\n\t}\n\treturn waveappstore.RenameAppFile(data.AppId, data.FromFileName, data.ToFileName)\n}\n\nfunc (ws *WshServer) WriteAppSecretBindingsCommand(ctx context.Context, data wshrpc.CommandWriteAppSecretBindingsData) error {\n\tif data.AppId == \"\" {\n\t\treturn fmt.Errorf(\"must provide an appId to WriteAppSecretBindingsCommand\")\n\t}\n\treturn waveappstore.WriteAppSecretBindings(data.AppId, data.Bindings)\n}\n\nfunc (ws *WshServer) DeleteBuilderCommand(ctx context.Context, builderId string) error {\n\tif builderId == \"\" {\n\t\treturn fmt.Errorf(\"must provide a builderId to DeleteBuilderCommand\")\n\t}\n\tbuildercontroller.DeleteController(builderId)\n\treturn nil\n}","sourceCodeStart":1099,"sourceCodeEnd":1135,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshrpc/wshserver/wshserver.go#L1099-L1135","documentation":"Wave Terminal's WSH RPC server validates that a RenameAppFileCommand request carries a non-empty AppId before delegating to waveappstore.RenameAppFile. The appId identifies which app's file store the rename targets; without it the operation would be ambiguous. The server rejects the call immediately with this error.","triggerScenarios":"Calling RenameAppFileCommand via wsh RPC with CommandRenameAppFileData where the AppId field is the empty string — e.g. the client built the data struct without filling AppId, or an upstream lookup that was supposed to supply the appId returned empty.","commonSituations":"Frontend code resolving an app from a block/tab context that has no associated app; stale or corrupted client state where the appId was lost; a caller constructing the command data by hand for scripting/testing and omitting the field.","solutions":["Populate CommandRenameAppFileData.AppId with the wave app's OID before invoking the RPC","Verify the caller's source of the appId (e.g. block controller or RTInfo lookup) actually returns a value","Log/inspect the outgoing RPC data payload to confirm AppId is serialized non-empty"],"exampleFix":"// before\ndata := wshrpc.CommandRenameAppFileData{FromFileName: \"a.json\", ToFileName: \"b.json\"}\n// after\ndata := wshrpc.CommandRenameAppFileData{AppId: appId, FromFileName: \"a.json\", ToFileName: \"b.json\"}","handlingStrategy":"validation","validationCode":"if data.AppId == \"\" {\n    return fmt.Errorf(\"cannot rename app file: AppId is empty\")\n}\nerr := client.RenameAppFileCommand(ctx, data)","typeGuard":"func hasAppId(data wshrpc.CommandRenameAppFileData) bool {\n    return data.AppId != \"\"\n}","tryCatchPattern":"if err := client.RenameAppFileCommand(ctx, data); err != nil {\n    if strings.Contains(err.Error(), \"must provide an appId\") {\n        // fix: resolve and set data.AppId, then retry once\n    }\n    return err\n}","preventionTips":["Always construct RPC data structs via helpers that fill AppId from the block/app context","Assert AppId non-empty in client code before every app-store RPC","Log the full RPC payload on failure for easier diagnosis"],"tags":["rpc","validation","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}