sipeed/picoclaw · error

failed to parse

Error message

failed to parse %s: %w

What it means

Default branch of wrapJSONError: the labeled document failed to parse with an error that is neither json.SyntaxError nor json.UnmarshalTypeError (e.g. unexpected EOF or other decoder errors). The original error is preserved via %w for errors.Is/As inspection.

Solutions

  1. Read the wrapped inner error for the specific parse failure
  2. Check the file is not empty or truncated
  3. Re-save the file as UTF-8 without BOM and retry
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at pkg/config/diagnostics.go:127 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/74d80240c77679ea. Report an issue: GitHub.

Appendix: source

Thrown at pkg/config/diagnostics.go:127

				"%s type error at line %d, column %d: expected %s but got %s\n%s",
				label,
				line,
				column,
				e.Type.String(),
				e.Value,
				preview,
			)
		}
		return fmt.Errorf(
			"%s type error at line %d, column %d: expected %s but got %s",
			label,
			line,
			column,
			e.Type.String(),
			e.Value,
		)
	default:
		return fmt.Errorf("failed to parse %s: %w", label, err)
	}
}

func splitDiagnosticError(message string) (string, string) {
	if idx := strings.IndexByte(message, '\n'); idx >= 0 {
		return message[:idx], message[idx+1:]
	}
	return message, ""
}

func stripANSISequences(s string) string {
	if s == "" {
		return ""
	}

	var b strings.Builder
	b.Grow(len(s))

View on GitHub (pinned to 49183d7e8d)