slimtoolkit/slim · warning
malformed find utf8: %s
Error message
malformed find utf8: %s
What it means
parseDetectUTF8 parses the xray --find-utf8 flag value (pkg/app/master/command/xray/cli.go:573). For values starting with 'dump:', the remainder must split into exactly 2 parts ('dump:<target>'), which effectively means any non-empty suffix; the check fails only when SplitN yields fewer than 2 parts. Because strings.SplitN(s, ":", 2) on any 'dump:'-prefixed string already yields at least 2 parts, this error is nearly unreachable in practice, but it guards the 'dump:target' contract where the target is a console marker, a directory, or a directory:path-regex:maxBytes spec.
Source
Thrown at pkg/app/master/command/xray/cli.go:573
matchers = append(matchers, &m)
}
return matchers, nil
}
func parseDetectUTF8(raw string) (*dockerimage.UTF8Detector, error) {
if raw == "" {
return nil, nil
}
var detector dockerimage.UTF8Detector
if raw == "dump" {
detector.Dump = true
detector.DumpConsole = true
} else if strings.HasPrefix(raw, "dump:") {
parts := strings.SplitN(raw, ":", 2)
if len(parts) != 2 {
return nil, fmt.Errorf("malformed find utf8: %s", raw)
}
detector.Dump = true
outTarget := strings.TrimSpace(parts[1])
if len(outTarget) == 0 || outTarget == dockerimage.CDMDumpToConsole {
detector.DumpConsole = true
} else {
if strings.Count(outTarget, ":") == 2 {
parts = strings.SplitN(outTarget, ":", 3)
if len(parts) != 3 {
return nil, fmt.Errorf("malformed find utf8: %s", raw)
}
outTarget = parts[0]
_ = parts[1] // TODO implemement path pattern matcher
maxSizeBytes := parts[2]
var err error
detector.MaxSizeBytes, err = strconv.Atoi(maxSizeBytes)View on GitHub (pinned to 81940d17fa)
Solutions
- Use one of the supported forms: 'dump' (console), 'dump:<dir>', or 'dump:<dir>:<path-regex>:<max-size-bytes>'.
- If you only want UTF-8 detection without dumping, pass a plain path pattern without the 'dump:' prefix.
- If this error appears, upgrade/check your slim version — the flag grammar may have changed between releases.
- Ensure the value after 'dump:' is non-empty (use 'dump:console' or an explicit directory).
Defensive patterns
Strategy: validation
Validate before calling
// validate a --find-utf8 value before invoking the CLI
func validFindUTF8(raw string) bool {
switch {
case raw == "" || raw == "dump":
return true
case strings.HasPrefix(raw, "dump:"):
target := strings.TrimPrefix(raw, "dump:")
if target == "" || !strings.Contains(target, ":") {
return true // console or plain dir
}
n := strings.Count(target, ":")
return n == 2 || n == 3
default:
return true // plain pattern
}
} Try / catch
detector, err := parseDetectUTF8(raw)
if err != nil {
if strings.HasPrefix(err.Error(), "malformed find utf8") {
fmt.Fprintf(os.Stderr, "use dump | dump:dir | dump:dir:path:maxBytes: %v\n", err)
os.Exit(2)
}
return err
} Prevention
- Prefer the simple forms: 'dump' or 'dump:<dir>'.
- If specifying max bytes, use the full 3-field target: dir:path:maxBytes.
- Avoid colons in the path-pattern portion of the target.
- Pin the slim version — the find-utf8 grammar has TODO gaps that may change.
When it happens
Trigger: Theoretically, a 'dump:'-prefixed --find-utf8 value that doesn't produce 2 SplitN fields — practically unreachable since any non-empty suffix after 'dump:' yields 2 fields; it acts as a defensive assertion in the parse path.
Common situations: Users constructing exotic 'dump:' values and hitting parse issues downstream (e.g. invalid MaxSizeBytes instead produce strconv errors); this specific error mainly surfaces if parsing logic or flag strings change between versions.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- malformed change data matcher: %s
- malformed change path matcher: %s
- malformed change data hash matcher: %s
- invalid operation - %s
- invalid order records value - %s
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/18e41bbe9519b10a.
Report an issue: GitHub.