{"record":{"id":"545f1f4f2b5ff969","repo":"rancher/rancher","slug":"failed-to-parse-jsonpath-w","errorCode":null,"errorMessage":"failed to parse jsonpath: %w","messagePattern":"failed to parse jsonpath: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/auth/audit/utils.go","lineNumber":91,"sourceCode":"\treturn compiled, nil\n}\n\nfunc matchesAny(s string, regexes []*regexp.Regexp) bool {\n\tfor _, re := range regexes {\n\t\tif re.MatchString(s) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc parsePaths(paths []string) ([]*jsonpath.JSONPath, error) {\n\tcompiled := make([]*jsonpath.JSONPath, len(paths))\n\tfor i, v := range paths {\n\t\tjp, err := jsonpath.Parse(v)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse jsonpath: %w\", err)\n\t\t}\n\t\tcompiled[i] = jp\n\t}\n\n\treturn compiled, nil\n}\n\nfunc pairMatches(v any, f func(string, any) bool) bool {\n\tswitch v := v.(type) {\n\tcase map[string]any:\n\t\tfor k, v := range v {\n\t\t\tif f(k, v) {\n\t\t\t\treturn true\n\t\t\t}\n\n\t\t\tif pairMatches(v, f) {\n\t\t\t\treturn true\n\t\t\t}","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/rancher/rancher/blob/932558d4e68565aff2d2f36e89ec4a391b06e7c5/pkg/auth/audit/utils.go#L73-L109","documentation":"parsePaths is the audit package's shared helper that parses a []string of redaction paths with github.com/rancher/jsonpath. It backs additionalRedactions[].paths parsing; a single malformed expression fails the whole list and the AuditPolicy is rejected.","triggerScenarios":"Any audit redaction configuration whose paths array contains one malformed JSONPath expression (bare path without braces, unclosed brace, invalid selector).","commonSituations":"Mixed-style paths where some entries use kubectl-style braces and others are bare; hand-edited CRs.","solutions":["Compile-check every path with jsonpath.Parse before applying","Standardize on the brace syntax ({.field.subfield})","Re-apply and confirm the policy loads"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import jsonpath \"github.com/rancher/jsonpath/pkg\"\n\nfunc validatePaths(paths []string) error {\n    for _, p := range paths {\n        if _, err := jsonpath.Parse(p); err != nil {\n            return fmt.Errorf(\"path %q: %w\", p, err)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the same jsonpath library version as Rancher when validating","Add sample-path tests to policy CI","Keep a library reference for the supported selector syntax"],"tags":["rancher","go","jsonpath","audit-log","redaction"],"backgroundTag":null,"analyzedSha":"932558d4e68565aff2d2f36e89ec4a391b06e7c5","analyzedAt":"2026-08-16T04:37:02.125Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}