moonD4rk/HackBrowserData · error
unsupported format: %s
Error message
unsupported format: %s
What it means
newFormatter maps a user-supplied output format name to a formatter implementation (csv, json, cookie-editor). Any other name is rejected at writer construction time, before any data is extracted or written. This is a fail-fast validation of the --format CLI/config value.
Source
Thrown at output/formatter.go:23
"io"
)
// formatter serializes rows to a writer. Unexported — only used by Writer.
type formatter interface {
format(w io.Writer, rows []row) error
ext() string
}
func newFormatter(name string) (formatter, error) {
switch name {
case "csv":
return &csvFormatter{}, nil
case "json":
return &jsonFormatter{}, nil
case "cookie-editor":
return &cookieEditorFormatter{fallback: &jsonFormatter{}}, nil
default:
return nil, fmt.Errorf("unsupported format: %s", name)
}
}
View on GitHub (pinned to 0503d04d7a)
Solutions
- Pass one of the exact supported names: csv, json, or cookie-editor (case-sensitive).
- Normalize the input to lowercase before calling NewWriter: strings.ToLower(format).
- Check the CLI help / NewWriter docs for the current supported format list.
- If another format is genuinely needed, add a formatter case in output/formatter.go implementing the formatter interface.
Example fix
// before
w, err := output.NewWriter(dir, "JSON", nil) // unsupported
// after
w, err := output.NewWriter(dir, strings.ToLower("JSON"), nil) // "json" Defensive patterns
Strategy: validation
Validate before calling
var supported = map[string]bool{"csv": true, "json": true, "cookie-editor": true}
if !supported[format] {
return fmt.Errorf("format %q not supported; use csv, json, or cookie-editor", format)
} Type guard
func isValidFormat(s string) bool {
switch s { case "csv", "json", "cookie-editor": return true }
return false
} Try / catch
w, err := output.NewWriter(dir, format, nil)
if err != nil && strings.Contains(err.Error(), "unsupported format") {
w, err = output.NewWriter(dir, "json", nil) // default fallback
} Prevention
- Validate the --format flag with a whitelist before calling NewWriter.
- Remember the switch is case-sensitive; lowercase user input.
- Check CLI help for the supported formats list.
When it happens
Trigger: NewWriter (via newFormatter) was called with a format name outside the supported set {csv, json, cookie-editor}, e.g. 'yaml', 'JSON' (case-sensitive), or an empty string.
Common situations: Typo in the CLI flag (--format jsn); wrong casing since the switch is case-sensitive; users assuming XML/YAML/HTML output exists; scripts passing a variable built from config that defaults to an unsupported value.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- yandex: encrypted intermediate key truncated
- abe: encrypted key too short: %d bytes
- abe: unexpected prefix: got %q, want %q
- encrypted_key too short: %d bytes
- encrypted_key unexpected prefix: got %q, want %q
AI-assisted analysis of moonD4rk/HackBrowserData@0503d04d7a (2026-09-06).
Data as JSON: /api/errors/d232f5a4601693f8.
Report an issue: GitHub.