{"record":{"id":"4e5e3fb4997c908c","repo":"grpc/grpc-java","slug":"unknown-stringmatcher-match-pattern","errorCode":null,"errorMessage":"Unknown StringMatcher match pattern: ","messagePattern":"Unknown StringMatcher match pattern: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"xds/src/main/java/io/grpc/xds/internal/MatcherParser.java","lineNumber":107,"sourceCode":"\n  /** Translate StringMatcher envoy proto to internal StringMatcher. */\n  public static Matchers.StringMatcher parseStringMatcher(\n            io.envoyproxy.envoy.type.matcher.v3.StringMatcher proto) {\n    switch (proto.getMatchPatternCase()) {\n      case EXACT:\n        return Matchers.StringMatcher.forExact(proto.getExact(), proto.getIgnoreCase());\n      case PREFIX:\n        return Matchers.StringMatcher.forPrefix(proto.getPrefix(), proto.getIgnoreCase());\n      case SUFFIX:\n        return Matchers.StringMatcher.forSuffix(proto.getSuffix(), proto.getIgnoreCase());\n      case SAFE_REGEX:\n        return Matchers.StringMatcher.forSafeRegEx(\n                Pattern.compile(proto.getSafeRegex().getRegex()));\n      case CONTAINS:\n        return Matchers.StringMatcher.forContains(proto.getContains(), proto.getIgnoreCase());\n      case MATCHPATTERN_NOT_SET:\n      default:\n        throw new IllegalArgumentException(\n                \"Unknown StringMatcher match pattern: \" + proto.getMatchPatternCase());\n    }\n  }\n\n  /** Translate StringMatcher xDS proto to internal StringMatcher. */\n  public static Matchers.StringMatcher parseStringMatcher(\n            com.github.xds.type.matcher.v3.StringMatcher proto) {\n    switch (proto.getMatchPatternCase()) {\n      case EXACT:\n        return Matchers.StringMatcher.forExact(proto.getExact(), proto.getIgnoreCase());\n      case PREFIX:\n        return Matchers.StringMatcher.forPrefix(\n            checkNonEmpty(proto.getPrefix(), \"prefix\"), proto.getIgnoreCase());\n      case SUFFIX:\n        return Matchers.StringMatcher.forSuffix(\n            checkNonEmpty(proto.getSuffix(), \"suffix\"), proto.getIgnoreCase());\n      case SAFE_REGEX:\n        String regex = checkNonEmpty(proto.getSafeRegex().getRegex(), \"regex\");","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/grpc/grpc-java/blob/64daddc1f3d1975670f769f3e97bde8b2ba32d25/xds/src/main/java/io/grpc/xds/internal/MatcherParser.java#L89-L125","documentation":"parseStringMatcher(envoy StringMatcher) switches over MatchPatternCase; when the Envoy StringMatcher has MATCHPATTERN_NOT_SET (or an unknown case) there is no valid match pattern, so IllegalArgumentException is thrown. The xDS config's string matcher (used inside header/path matchers) is empty or uses an unsupported pattern type.","triggerScenarios":"A StringMatcher proto in route/virtual-host config with no exact/safe_regex/prefix/suffix/contains field set, or a case added in a newer Envoy API than this parser supports.","commonSituations":"Management server serializes an empty StringMatcher {} for a header match; config tooling drops the pattern field; client library older than the control plane's Envoy API version.","solutions":["Set exactly one match pattern field (exact, safe_regex, prefix, suffix, contains) on the StringMatcher in the xDS config","Upgrade grpc-xds so the MatchPatternCase is recognized","Inspect the logged MatchPatternCase value to find the offending config entry","Regenerate config from a template that always populates the pattern"],"exampleFix":"// before\n{\"string_match\":{}}\n// after\n{\"string_match\":{\"exact\":\"v2\"}}","handlingStrategy":"validation","validationCode":"if (proto.getMatchPatternCase() == StringMatcher.MatchPatternCase.MATCHPATTERN_NOT_SET) { reject(\"string_match empty\"); }","typeGuard":"null","tryCatchPattern":"try { sm = MatcherParser.parseStringMatcher(proto); }\ncatch (IllegalArgumentException e) { log.error(\"Bad StringMatcher: \" + e.getMessage()); reject(); }","preventionTips":["Ensure string_match sets one pattern field","Keep client and control-plane Envoy API versions aligned","Add schema validation at the management server"],"tags":["xds","config","envoy","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"64daddc1f3d1975670f769f3e97bde8b2ba32d25","analyzedAt":"2026-09-08T06:14:57.704Z","contentChangedAt":"2026-09-08T06:14:57.704Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}