{"record":{"id":"192248f6700edf67","repo":"juanfont/headscale","slug":"marshalling-json-line-output-w","errorCode":null,"errorMessage":"marshalling JSON-line output: %w","messagePattern":"marshalling JSON-line output: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/headscale/cli/utils.go","lineNumber":296,"sourceCode":"\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:\n\t\treturn override, nil\n\t}\n}\n\n// printOutput formats result and writes it to stdout. It reads the --output\n// flag from cmd to decide the serialisation format.\nfunc printOutput(cmd *cobra.Command, result any, override string) error {","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/cmd/headscale/cli/utils.go#L278-L314","documentation":"Error \"marshalling JSON-line output: %w\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at cmd/headscale/cli/utils.go:296 when the library encounters an invalid state.","commonSituations":"Serializing the result to JSON-lines output failed. Check for incompatible CLI/server versions producing unserializable fields.","solutions":["Inspect the wrapped error for the underlying cause and correct the failing condition (marshalling JSON-line 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-line 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-15T17:31:12.345Z"}