{"record":{"id":"a9d50bde7de3a8f3","repo":"wavetermdev/waveterm","slug":"json-encoding-w","errorCode":null,"errorMessage":"json encoding: %w","messagePattern":"json encoding: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-web.go","lineNumber":87,"sourceCode":"\t\tBlockId:     fullORef.OID,\n\t\tTabId:       blockInfo.TabId,\n\t\tSelector:    args[0],\n\t\tOpts: &wshrpc.WebSelectorOpts{\n\t\t\tInner: webGetInner,\n\t\t\tAll:   webGetAll,\n\t\t},\n\t}\n\toutput, err := wshclient.WebSelectorCommand(RpcClient, data, &wshrpc.RpcOpts{\n\t\tRoute:   wshutil.ElectronRoute,\n\t\tTimeout: 5000,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\tif webGetJson {\n\t\tbarr, err := json.MarshalIndent(output, \"\", \"  \")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"json encoding: %w\", err)\n\t\t}\n\t\tWriteStdout(\"%s\\n\", string(barr))\n\t} else {\n\t\tfor _, item := range output {\n\t\t\tWriteStdout(\"%s\\n\", item)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc webOpenRun(cmd *cobra.Command, args []string) (rtnErr error) {\n\tdefer func() {\n\t\tsendActivity(\"web\", rtnErr == nil)\n\t}()\n\n\tvar replaceBlockORef *waveobj.ORef\n\tif webOpenReplaceBlock != \"\" {\n\t\tvar err error","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-web.go#L69-L105","documentation":"When the --json flag (webGetJson) is set, webGetRun marshals the selector output with json.MarshalIndent. If marshaling fails — which is unexpected for plain string/slice output but possible for non-serializable values — the error is wrapped with \"json encoding:\".","triggerScenarios":"`wsh web get --json` where json.MarshalIndent cannot serialize the output value (e.g. unsupported types, channels, funcs, or cyclic data introduced by upstream changes).","commonSituations":"Custom or corrupted builds where the output struct contains non-JSON-safe fields; very rare in practice since output is []string.","solutions":["Retry without --json; the plain-text path prints each item directly","Update wsh to a version where the web get output is a JSON-serializable type","If developing, ensure the output type contains only JSON-supported fields"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"barr, err := json.MarshalIndent(output, \"\", \"  \")\nif err != nil {\n    return fmt.Errorf(\"json encoding: %w\", err)\n}","preventionTips":["Keep CLI JSON output types limited to JSON-safe fields","Test the --json path in CI","Fall back to plain-text output when marshaling fails"],"tags":["json","serialization","cli"],"backgroundTag":"json-serialization-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}