juanfont/headscale · error

marshalling JSON output: %w

Error message

marshalling JSON output: %w

What it means

Error "marshalling JSON output: %w" thrown in juanfont/headscale.

Source

Thrown at cmd/headscale/cli/utils.go:289

	return clientv1.NewClientWithResponses(
		clientBaseURL(address),
		clientv1.WithHTTPClient(httpClient),
		clientv1.WithRequestEditorFn(func(_ context.Context, req *http.Request) error {
			req.Header.Set("Authorization", "Bearer "+apiKey)

			return nil
		}),
	)
}

// formatOutput serialises result into the requested format. For the
// default (empty) format the human-readable override string is returned.
func formatOutput(result any, override string, outputFormat string) (string, error) {
	switch outputFormat {
	case outputFormatJSON:
		b, err := json.MarshalIndent(result, "", "\t")
		if err != nil {
			return "", fmt.Errorf("marshalling JSON output: %w", err)
		}

		return string(b), nil
	case outputFormatJSONLine:
		b, err := json.Marshal(result)
		if err != nil {
			return "", fmt.Errorf("marshalling JSON-line output: %w", err)
		}

		return string(b), nil
	case outputFormatYAML:
		b, err := yaml.Marshal(result)
		if err != nil {
			return "", fmt.Errorf("marshalling YAML output: %w", err)
		}

		return string(b), nil
	default:

View on GitHub (pinned to 565fd254d0)

Solutions

  1. 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.

Example fix

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.

When it happens

Trigger: Thrown at cmd/headscale/cli/utils.go:289 when the library encounters an invalid state.

Common situations: Serializing the command result to JSON failed. This indicates an unexpected value in the response; ensure CLI and server versions are compatible.


AI-assisted analysis of juanfont/headscale@565fd254d0 (2026-08-15). Data as JSON: /api/errors/56d528b7d8968011. Report an issue: GitHub.