elastic/elasticsearch · error · IllegalArgumentException
Invalid language tag specified: {}
Error message
Invalid language tag specified: {} What it means
Thrown by DateIndexNameProcessor.Factory when java.util.Locale.Builder.setLanguageTag rejects the configured 'locale' string with IllformedLocaleException. The factory catches the IllformedLocaleException and rethrows as IllegalArgumentException. A valid BCP 47 tag (e.g. 'en-US') is required; malformed tags do not fall back to the default English locale.
Source
Thrown at modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/DateIndexNameProcessor.java:165
}
@Override
public DateIndexNameProcessor create(
Map<String, Processor.Factory> registry,
String tag,
String description,
Map<String, Object> config,
ProjectId projectId
) throws Exception {
String localeString = ConfigurationUtils.readOptionalStringProperty(TYPE, tag, config, "locale");
String timezoneString = ConfigurationUtils.readOptionalStringProperty(TYPE, tag, config, "timezone");
ZoneId timezone = timezoneString == null ? ZoneOffset.UTC : ZoneId.of(timezoneString);
Locale locale = Locale.ENGLISH;
if (localeString != null) {
try {
locale = (new Locale.Builder()).setLanguageTag(localeString).build();
} catch (IllformedLocaleException e) {
throw new IllegalArgumentException("Invalid language tag specified: " + localeString);
}
}
List<String> dateFormatStrings = ConfigurationUtils.readOptionalList(TYPE, tag, config, "date_formats");
if (dateFormatStrings == null) {
dateFormatStrings = Collections.singletonList("yyyy-MM-dd'T'HH:mm:ss.SSSXX");
}
List<Function<String, ZonedDateTime>> dateFormats = new ArrayList<>(dateFormatStrings.size());
for (String format : dateFormatStrings) {
DateFormat dateFormat = DateFormat.fromString(format);
dateFormats.add(dateFormat.getFunction(format, timezone, locale));
}
String field = ConfigurationUtils.readStringProperty(TYPE, tag, config, "field");
String indexNamePrefix = ConfigurationUtils.readStringProperty(TYPE, tag, config, "index_name_prefix", "");
TemplateScript.Factory indexNamePrefixTemplate = ConfigurationUtils.compileTemplate(
TYPE,
tag,
"index_name_prefix",View on GitHub (pinned to db6a809a66)
Solutions
- Use a hyphenated BCP 47 language tag such as 'en-US', 'fr-FR', 'de', 'ja-JP'.
- Omit the 'locale' option to fall back to the default Locale.ENGLISH.
- Validate the locale string with java.util.Locale.LanguageRange.parse or Locale.forLanguageTag before deploying.
Example fix
// before
{"date_index_name": {"field": "ts", "index_name_prefix": "logs-", "date_rounding": "d", "locale": "en_US"}}
// after
{"date_index_name": {"field": "ts", "index_name_prefix": "logs-", "date_rounding": "d", "locale": "en-US"}} Defensive patterns
Strategy: validation
Validate before calling
// Validate the locale string with java before deploying (outside ES, e.g. in CI pipeline validation):
// Locale.forLanguageTag("en-US"); // ok
// Locale.forLanguageTag("en_US"); // silently lenient; use Locale.Builder to validate BCP47 strictly:
new Locale.Builder().setLanguageTag("en-US").build(); Prevention
- Always use hyphenated BCP 47 tags ('en-US', 'fr-FR').
- Omit the locale option when English is acceptable.
- Validate locale strings in CI by running a dry pipeline creation.
When it happens
Trigger: Configuring the date_index_name processor's 'locale' option with a string that violates BCP 47 syntax, e.g. 'en_US' (underscore), 'english', 'en-US-x', or trailing subtags.
Common situations: Developers using underscore-separated locale strings (common in Java resource bundles) instead of hyphenated BCP 47; copy-pasting locale names from other systems; locale typos.
Related errors
- field [{}] is null, cannot process it.
- unable to convert [{}] to double
- Field [{}] is null, cannot be converted to type [{}]
- field [{}] is null, cannot process it.
- unable to parse date [{}]
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/ba07f37b73f7bccf.
Report an issue: GitHub.