{"record":{"id":"e89686f67db1df61","repo":"elastic/elasticsearch","slug":"illegal-property-value-valid-values-are","errorCode":null,"errorMessage":"illegal property value [{}]. valid values are {}","messagePattern":"illegal property value \\[(.+?)\\]\\. valid values are (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"libs/ip-location-api/src/main/java/org/elasticsearch/iplocation/api/DatabaseProperty.java","lineNumber":130,"sourceCode":"     * @param validProperties the valid properties against which to validate the parsed property value\n     * @param value the string representation to parse\n     * @return a parsed, validated DatabaseProperty\n     * @throws IllegalArgumentException if the value does not parse as a DatabaseProperty or if the parsed value is not\n     * in the passed-in validProperties set\n     */\n    public static DatabaseProperty parseProperty(final Set<DatabaseProperty> validProperties, final String value) {\n        try {\n            DatabaseProperty property = valueOf(value.toUpperCase(Locale.ROOT));\n            if (validProperties.contains(property) == false) {\n                throw new IllegalArgumentException(\"invalid\");\n            }\n            return property;\n        } catch (IllegalArgumentException e) {\n            // put the properties in natural order before throwing so that we have reliable error messages -- this is a little\n            // bit inefficient, but we only do this validation at processor construction time so the cost is practically immaterial\n            DatabaseProperty[] properties = validProperties.toArray(new DatabaseProperty[0]);\n            Arrays.sort(properties);\n            throw new IllegalArgumentException(\"illegal property value [\" + value + \"]. valid values are \" + Arrays.toString(properties));\n        }\n    }\n}\n","sourceCodeStart":112,"sourceCodeEnd":134,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/ip-location-api/src/main/java/org/elasticsearch/iplocation/api/DatabaseProperty.java#L112-L134","documentation":"Thrown by DatabaseProperty.parseProperty when the supplied string is not a valid DatabaseProperty enum name, or is a valid enum but not in the validProperties set for the current database. The message lists the allowed values in natural order. This validation runs once at processor construction time, so the sorting overhead is intentional for stable, readable errors.","triggerScenarios":"Calling DatabaseProperty.parseProperty(validProperties, value) where `value` is either not parseable by valueOf (typo / unknown name) or parses but is excluded from validProperties (e.g. a field the loaded MaxMind database edition does not provide). The uppercased value is matched against the enum constants like COUNTRY_NAME, ASN, TOR_EXIT_NODE, etc.","commonSituations":"Configuring the ip-location ingest processor with a property name that the active database does not expose. Typos such as 'county_name' instead of 'country_name'. Using enterprise-only properties (e.g. ASN, anonymous_vpn) against a free City database. Mismatch between the field name string from IpDataLookupInfo and the enum.","solutions":["Read the 'valid values are [...]' list in the error message and use one of those exact values.","Cross-check the requested property against DatabaseProperty enum constants and confirm the database edition actually populates that field (build the validProperties set via DatabaseProperty.buildValidSet(info.getFields().keySet())).","If the property is legitimately needed, switch to a database edition/license tier that includes it.","Fix typos: field strings are case-insensitive but must match an enum name (e.g. COUNTRY_NAME), not an arbitrary label."],"exampleFix":"// before\nDatabaseProperty p = DatabaseProperty.parseProperty(validProps, \"county_name\");\n\n// after\nDatabaseProperty p = DatabaseProperty.parseProperty(validProps, \"country_name\");","handlingStrategy":"validation","validationCode":"// Validate before calling parseProperty\nSet<DatabaseProperty> valid = DatabaseProperty.buildValidSet(info.getFields().keySet());\nString candidate = \"country_name\"; // user-supplied\nboolean ok = false;\nfor (DatabaseProperty dp : valid) {\n    if (dp.name().equalsIgnoreCase(candidate)) { ok = true; break; }\n}\nif (!ok) {\n    throw new IllegalArgumentException(\"Not a supported property for this database: \" + candidate);\n}\nDatabaseProperty p = DatabaseProperty.parseProperty(valid, candidate);","typeGuard":"// Returns true only if `value` maps to a DatabaseProperty in the valid set\nstatic boolean isValidProperty(Set<DatabaseProperty> valid, String value) {\n    if (value == null) return false;\n    try {\n        DatabaseProperty dp = DatabaseProperty.valueOf(value.toUpperCase(Locale.ROOT));\n        return valid.contains(dp);\n    } catch (IllegalArgumentException e) {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    DatabaseProperty p = DatabaseProperty.parseProperty(validProperties, value);\n} catch (IllegalArgumentException e) {\n    // e.getMessage() already lists valid values; surface to config/UI\n    throw newConfigurationException(\"ip-location property\", value, e.getMessage());\n}","preventionTips":["Build the valid set from the database's actual fields via DatabaseProperty.buildValidSet(info.getFields().keySet()) before parsing user input.","Whitelist user-facing property choices against the valid set in the UI/config layer, not just at parse time.","Use the enum's name() values (uppercased) as the canonical string form to avoid typos."],"tags":["config","validation","ip-location","enum","ingest-processor"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}