{"record":{"id":"56d528b7d8968011","repo":"juanfont/headscale","slug":"marshalling-json-output-w","errorCode":null,"errorMessage":"marshalling JSON output: %w","messagePattern":"marshalling JSON output: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/headscale/cli/utils.go","lineNumber":289,"sourceCode":"\treturn clientv1.NewClientWithResponses(\n\t\tclientBaseURL(address),\n\t\tclientv1.WithHTTPClient(httpClient),\n\t\tclientv1.WithRequestEditorFn(func(_ context.Context, req *http.Request) error {\n\t\t\treq.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n\n\t\t\treturn nil\n\t\t}),\n\t)\n}\n\n// formatOutput serialises result into the requested format. For the\n// default (empty) format the human-readable override string is returned.\nfunc formatOutput(result any, override string, outputFormat string) (string, error) {\n\tswitch outputFormat {\n\tcase outputFormatJSON:\n\t\tb, err := json.MarshalIndent(result, \"\", \"\\t\")\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"marshalling JSON output: %w\", err)\n\t\t}\n\n\t\treturn string(b), nil\n\tcase outputFormatJSONLine:\n\t\tb, err := json.Marshal(result)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"marshalling JSON-line output: %w\", err)\n\t\t}\n\n\t\treturn string(b), nil\n\tcase outputFormatYAML:\n\t\tb, err := yaml.Marshal(result)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"marshalling YAML output: %w\", err)\n\t\t}\n\n\t\treturn string(b), nil\n\tdefault:","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/cmd/headscale/cli/utils.go#L271-L307","documentation":"Error \"marshalling JSON output: %w\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at cmd/headscale/cli/utils.go:289 when the library encounters an invalid state.","commonSituations":"Serializing the command result to JSON failed. This indicates an unexpected value in the response; ensure CLI and server versions are compatible.","solutions":["Inspect the wrapped error for the underlying cause and correct the failing condition (marshalling JSON output); retry the operation after fixing the input, configuration, or environment."],"exampleFix":"Inspect the wrapped error for the underlying cause and correct the failing condition (marshalling JSON output); retry the operation after fixing the input, configuration, or environment.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}