{"record":{"id":"7dcc60e1c16d5e81","repo":"elastic/elasticsearch","slug":"contains-disallowed-characters","errorCode":null,"errorMessage":"'{}' contains disallowed characters","messagePattern":"'(.+?)' contains disallowed characters","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/RerouteProcessor.java","lineNumber":265,"sourceCode":"                if (value.startsWith(\"{{\") == false || value.endsWith(\"}}\") == false) {\n                    throw new IllegalArgumentException(\"'\" + value + \"' is not a valid field reference\");\n                }\n                String fieldReference = value.substring(2, value.length() - 2);\n                // field references may have two or three curly braces\n                if (fieldReference.startsWith(\"{\") && fieldReference.endsWith(\"}\")) {\n                    fieldReference = fieldReference.substring(1, fieldReference.length() - 1);\n                }\n                fieldReference = fieldReference.trim();\n                // only a single field reference is allowed\n                // so something like this is disallowed: {{foo}}-{{bar}}\n                if (fieldReference.contains(\"{\") || fieldReference.contains(\"}\")) {\n                    throw new IllegalArgumentException(\"'\" + value + \"' is not a valid field reference\");\n                }\n                this.fieldReference = fieldReference;\n            } else {\n                this.fieldReference = null;\n                if (Objects.equals(sanitizer.apply(value), value) == false) {\n                    throw new IllegalArgumentException(\"'\" + value + \"' contains disallowed characters\");\n                }\n            }\n        }\n\n        /**\n         * Resolves the field reference from the provided ingest document or returns the static value if this value source doesn't represent\n         * a field reference.\n         * @param ingestDocument\n         * @return the resolved field reference or static value\n         */\n        @Nullable\n        public String resolve(IngestDocument ingestDocument) {\n            if (fieldReference != null) {\n                String value = ingestDocument.getFieldValue(fieldReference, String.class, true);\n                if (value == null) {\n                    value = getStringFieldValueInDottedNotation(ingestDocument);\n                }\n                return sanitizer.apply(value);","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/RerouteProcessor.java#L247-L283","documentation":"Thrown in the DataStreamValueSource constructor when the value is a static string (no field-reference markers) but fails sanitization via DataStream.sanitizeType/Dataset/Namespace. This means the static value contains characters not allowed in data stream name segments.","triggerScenarios":"Configuring reroute with a static type/dataset/namespace containing invalid characters such as uppercase letters, spaces, commas, colons, or other disallowed symbols for data stream names.","commonSituations":"Using mixed-case or special characters in dataset names (e.g., 'My App Logs'). Including spaces, slashes, or punctuation that data stream naming rules reject.","solutions":["Use only lowercase alphanumeric characters, hyphens, underscores, and dots as required by data stream naming.","Run the value through the appropriate DataStream.sanitize* method before setting it.","Rename static values to comply with the <type>-<dataset>-<namespace> rules (lowercase, no invalid punctuation)."],"exampleFix":"// before\n{\n  \"reroute\": { \"dataset\": \"My App Logs\" }\n}\n// after\n{\n  \"reroute\": { \"dataset\": \"my_app_logs\" }\n}","handlingStrategy":"validation","validationCode":"// Validate static data-stream segment values pass sanitization\nString value = \"my_dataset\"; // example\nString sanitized = DataStream.sanitizeDataset(value);\nif (!sanitized.equals(value)) {\n    throw new IllegalArgumentException(\"value contains disallowed characters: \" + value);\n}","typeGuard":"boolean isValidStaticSegment(String value) {\n    if (value == null) return false;\n    // data stream names: lowercase, alphanumeric, hyphens, underscores, dots\n    return value.matches(\"^[a-z0-9][a-z0-9._-]*[a-z0-9]$\") || value.matches(\"^[a-z0-9]$\");\n}","tryCatchPattern":"try {\n    // build reroute processor with static value\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"contains disallowed characters\")) {\n        // sanitize or rename the static value to lowercase alphanumerics\n    } else { throw e; }\n}","preventionTips":["Use only lowercase alphanumeric characters, hyphens, underscores, and dots in static segments.","Run static values through DataStream.sanitizeType/Dataset/Namespace before deployment.","Avoid spaces, uppercase letters, and punctuation in dataset/namespace/type config."],"tags":["elasticsearch","ingest-pipeline","reroute","data-stream","validation","sanitization"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}