docker/compose · error
format value %q could not be parsed: %w
Error message
format value %q could not be parsed: %w
What it means
Returned by formatter.Print (used by list-style commands such as `docker compose ls`, `ps`, `images` with --format) when the requested --format value matches none of the accepted cases: table/pretty/empty, the legacy 'json' TemplateLegacyJSON, or 'json' after strings.ToLower normalization — plus any command-specific template handling done before this call. The error wraps api.ErrParsingFailed and echoes the offending value so the user sees exactly what was rejected.
Source
Thrown at cmd/formatter/formatter.go:68
_, _ = fmt.Fprintln(outWriter, outJSON)
}
case JSON:
switch reflect.TypeOf(toJSON).Kind() {
case reflect.Slice:
outJSON, err := ToJSON(toJSON, "", "")
if err != nil {
return err
}
_, _ = fmt.Fprint(outWriter, outJSON)
default:
outJSON, err := ToStandardJSON(toJSON)
if err != nil {
return err
}
_, _ = fmt.Fprintln(outWriter, outJSON)
}
default:
return fmt.Errorf("format value %q could not be parsed: %w", format, api.ErrParsingFailed)
}
return nil
}
View on GitHub (pinned to ddc4b044b6)
Solutions
- Use a supported value: `--format table` (default), `--format pretty`, or `--format json`.
- For custom output, consume `--format json` and transform with jq/yq downstream.
- Check the specific command's --help to see whether Go templates are accepted; if yes use `--format '{{...}}'`, else stick to json.
Example fix
# before docker compose ls --format yaml # after docker compose ls --format json | yq -P
Defensive patterns
Strategy: validation
Validate before calling
case "$(echo "$FMT" | tr '[:upper:]' '[:lower:]')" in table|pretty|json|'') : ;; *) echo "unsupported --format: $FMT (use table|pretty|json)" >&2; exit 2;; esac docker compose ls --format "$FMT"
Prevention
- Pin wrappers to --format json and post-process with jq/yq.
- Check each command's --help before using templates or exotic formats.
- Don't assume docker CLI format sets transfer to compose commands.
When it happens
Trigger: Passing an unsupported format: `docker compose ls --format yaml`, `--format csv`, or a Go template string where templates are not supported for that command; case is normalized (JSON works), but any other token falls to the default branch and errors.
Common situations: Scripts assuming jq-style universal formats (yaml/csv); copy-pasting `--format '{{.Name}}'` from a command that supports templates into one routed through formatter.Print without template support; typos like `--format jso`; version drift where a format existed in another tool (docker CLI supports more formats).
Related errors
- unsupported format %q
- unsupported format %q
- invalid scale specifier: %s
- invalid scale specifier: can't parse replica value as int: %
- cannot combine %s and --remove-orphans
AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15).
Data as JSON: /api/errors/d4f9f9e9fa70fed2.
Report an issue: GitHub.