{"record":{"id":"41a46a3928accd8f","repo":"spring-projects/spring-security","slug":"no-enum-constant-org-springframework-security-oaut","errorCode":null,"errorMessage":"No enum constant org.springframework.security.oauth2.client.registration.CommonOAuth2Provider.{value}","messagePattern":"No enum constant org\\.springframework\\.security\\.oauth2\\.client\\.registration\\.CommonOAuth2Provider\\.(.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"config/src/main/java/org/springframework/security/config/oauth2/client/ClientRegistrationsBeanDefinitionParser.java","lineNumber":249,"sourceCode":"\t\t\t}\n\t\t\tcatch (Exception ex) {\n\t\t\t\treturn findEnum(value);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate static CommonOAuth2Provider findEnum(String value) {\n\t\tString name = getCanonicalName(value);\n\t\tfor (CommonOAuth2Provider candidate : EnumSet.allOf(CommonOAuth2Provider.class)) {\n\t\t\tString candidateName = getCanonicalName(candidate.name());\n\t\t\tif (name.equals(candidateName)) {\n\t\t\t\treturn candidate;\n\t\t\t}\n\t\t}\n\t\tthrow new IllegalArgumentException(\n\t\t\t\t\"No enum constant \" + CommonOAuth2Provider.class.getCanonicalName() + \".\" + value);\n\t}\n\n\tprivate static String getCanonicalName(String name) {\n\t\tStringBuilder canonicalName = new StringBuilder(name.length());\n\t\tname.chars()\n\t\t\t.filter(Character::isLetterOrDigit)\n\t\t\t.map(Character::toLowerCase)\n\t\t\t.forEach((c) -> canonicalName.append((char) c));\n\t\treturn canonicalName.toString();\n\t}\n\n\tprivate static String getErrorMessage(String configuredProviderId, String registrationId) {\n\t\treturn (configuredProviderId != null) ? \"Unknown provider ID '\" + configuredProviderId + \"'\"\n\t\t\t\t: \"Provider ID must be specified for client registration '\" + registrationId + \"'\";\n\t}\n\n}","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/spring-projects/spring-security/blob/96852e8860138a482cb13d1479573f24ff6443c6/config/src/main/java/org/springframework/security/config/oauth2/client/ClientRegistrationsBeanDefinitionParser.java#L231-L267","documentation":"ClientRegistrationsBeanDefinitionParser resolves a common OAuth2 provider name to the CommonOAuth2Provider enum using case-insensitive canonical-name matching. If the configured registration id does not match any enum constant, it throws IllegalArgumentException listing the missing enum name.","triggerScenarios":"In Spring XML OAuth2 client configuration (<client-registrations>) specifying a provider value that is not one of CommonOAuth2Provider's constants (e.g. a typo like 'gogle' or an unsupported provider like 'linkedin').","commonSituations":"Migrating properties-based OAuth2 config to XML; using a provider name valid in Spring Boot's properties but not in CommonOAuth2Provider; misspelling GOOGLE, GITHUB, FACEBOOK, or OKTA.","solutions":["Use one of the supported CommonOAuth2Provider values: google, github, facebook, okta (case/underscores normalized)","Check spelling of the provider value in the XML configuration","For providers not in CommonOAuth2Provider, define the ClientRegistration manually (builder or properties file) instead of the common-provider shorthand"],"exampleFix":"// before\n<oauth2-client:client-registrations>\n  <oauth2-client:client-registration registration-id=\"gogle\" client-id=\"abc\" client-secret=\"xyz\"/>\n</oauth2-client:client-registrations>\n\n// after\n<oauth2-client:client-registrations>\n  <oauth2-client:client-registration registration-id=\"google\" client-id=\"abc\" client-secret=\"xyz\"/>\n</oauth2-client:client-registrations>","handlingStrategy":"validation","validationCode":"boolean valid;\ntry {\n  CommonOAuth2Provider.valueOf(value.toUpperCase());\n  valid = true;\n} catch (IllegalArgumentException e) {\n  valid = false;\n}\nif (!valid) throw new IllegalArgumentException(value + \" is not a CommonOAuth2Provider (google, github, facebook, okta)\");","typeGuard":null,"tryCatchPattern":"try {\n  ClientRegistrations.fromIssuerLocation(issuer);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"No enum constant\")) {\n    // fall back to a manual ClientRegistration builder\n  }\n}","preventionTips":["Only use provider ids supported by CommonOAuth2Provider in XML shorthand","For other providers, use spring.security.oauth2.client.registration.* properties or a manual builder","Validate provider names at startup with a unit test"],"tags":["oauth2","enum","configuration","spring-security"],"backgroundTag":"invalid-enum-value","analyzedSha":"96852e8860138a482cb13d1479573f24ff6443c6","analyzedAt":"2026-09-10T23:25:23.477Z","contentChangedAt":"2026-09-10T23:25:23.477Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}