{"record":{"id":"9e3e34ab313c6ba9","repo":"slimtoolkit/slim","slug":"malformed-change-data-matcher-s","errorCode":null,"errorMessage":"malformed change data matcher: %s","messagePattern":"malformed change data matcher: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/master/command/xray/cli.go","lineNumber":432,"sourceCode":"\t\t\toutputs[\"report\"] = struct{}{}\n\t\tcase \"console\":\n\t\t\toutputs[\"console\"] = struct{}{}\n\t\t}\n\t}\n\n\treturn outputs, nil\n}\n\nfunc parseChangeDataMatchers(values []string) ([]*dockerimage.ChangeDataMatcher, error) {\n\tvar matchers []*dockerimage.ChangeDataMatcher\n\n\tfor _, raw := range values {\n\t\tvar m dockerimage.ChangeDataMatcher\n\n\t\tif strings.HasPrefix(raw, \"dump:\") {\n\t\t\tparts := strings.SplitN(raw, \":\", 4)\n\t\t\tif len(parts) != 4 {\n\t\t\t\treturn nil, fmt.Errorf(\"malformed change data matcher: %s\", raw)\n\t\t\t}\n\n\t\t\tm.Dump = true\n\n\t\t\toutTarget := strings.TrimSpace(parts[1])\n\t\t\tif len(outTarget) == 0 || outTarget == dockerimage.CDMDumpToConsole {\n\t\t\t\tm.DumpConsole = true\n\t\t\t} else {\n\t\t\t\tm.DumpDir = outTarget\n\t\t\t}\n\n\t\t\tm.PathPattern = parts[2]\n\t\t\tm.DataPattern = parts[3]\n\n\t\t\t//\"dump:output:path_ptrn:data_regex\"\n\t\t\t//\"::path_ptrn:data_regex\"\n\t\t\t//\":::data_regex\"\n\t\t\t//\"data_regex\"","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/master/command/xray/cli.go#L414-L450","documentation":"parseChangeDataMatchers in the xray command (pkg/app/master/command/xray/cli.go:432) parses --change-data matcher values. A value starting with 'dump:' must have the 4-part form 'dump:output:path_pattern:data_regex' (SplitN on ':' into exactly 4 parts); anything with fewer separators, e.g. 'dump:console' or 'dump:dir:regex', fails and returns \"malformed change data matcher: %s\".","triggerScenarios":"Passing a --change-data value beginning with 'dump:' that does not contain three ':' separators producing exactly 4 fields — e.g. 'dump:console', 'dump:/tmp/out', 'dump:/tmp/out:.*' (only 3 parts).","commonSituations":"Users forget the path-pattern field even when it should be empty, writing 'dump:out:regex' instead of 'dump:out::regex'; quoting issues in shell cause ':' groups to be lost; copy-pasting examples that dropped one of the empty middle fields.","solutions":["Use the full 4-field form: dump:<output-dir-or-empty>:<path-pattern>:<data-regex>, e.g. dump:/tmp/out::'(?i)password'.","If the path pattern is empty, keep the separator: dump:out::regex or :::regex.","If you only want a data regex with no dump, drop the 'dump:' prefix entirely (e.g. just '(?i)secret').","Count the colons: a dump-prefixed data matcher needs exactly 3 colons (4 fields)."],"exampleFix":"// before\n--change-data 'dump:/tmp/dump:PASSWORD.*'\n// after\n--change-data 'dump:/tmp/dump::PASSWORD.*'","handlingStrategy":"validation","validationCode":"// validate a dump-form change-data matcher before passing it to the CLI\nfunc validDataMatcher(raw string) bool {\n    if !strings.HasPrefix(raw, \"dump:\") {\n        return true // plain regex form\n    }\n    return len(strings.SplitN(raw, \":\", 4)) == 4\n}","typeGuard":null,"tryCatchPattern":"matchers, err := parseChangeDataMatchers(values)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"malformed change data matcher\") {\n        fmt.Fprintf(os.Stderr, \"expected dump:out:path_pattern:data_regex (3 colons) or plain regex: %v\\n\", err)\n        os.Exit(2)\n    }\n    return err\n}","preventionTips":["Quote matcher values in shell so empty fields survive: 'dump:out::regex'.","Remember the field counts: data matcher dump form = 4 fields (3 colons).","Test complex matchers against strings.SplitN(value, \":\", 4) before deploying.","Prefer plain-regex form when the path pattern is not needed."],"tags":["cli","xray","matcher-syntax","slimtoolkit"],"backgroundTag":"malformed-matcher-syntax","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}