From 97fd2e9963b627957c13ad817b301c4e97393b08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Massot?= Date: Thu, 29 Jun 2023 16:14:59 +0200 Subject: [PATCH] Allow dots in identifier. (#3592) --- quickwit/quickwit-config/src/lib.rs | 6 ++++-- .../quickwit-integration-tests/src/tests/index_tests.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/quickwit/quickwit-config/src/lib.rs b/quickwit/quickwit-config/src/lib.rs index f2e7f55c28e..303dab7b5da 100644 --- a/quickwit/quickwit-config/src/lib.rs +++ b/quickwit/quickwit-config/src/lib.rs @@ -107,14 +107,14 @@ pub fn validate_identifier(label: &str, value: &str) -> anyhow::Result<()> { static IDENTIFIER_REGEX: OnceCell = OnceCell::new(); if IDENTIFIER_REGEX - .get_or_init(|| Regex::new(r"^[a-zA-Z][a-zA-Z0-9-_]{2,254}$").expect("Failed to compile regular expression. This should never happen! Please, report on https://github.com/quickwit-oss/quickwit/issues.")) + .get_or_init(|| Regex::new(r"^[a-zA-Z][a-zA-Z0-9-_\.]{2,254}$").expect("Failed to compile regular expression. This should never happen! Please, report on https://github.com/quickwit-oss/quickwit/issues.")) .is_match(value) { return Ok(()); } bail!( "{label} identifier `{value}` is invalid. Identifiers must match the following regular \ - expression: `^[a-zA-Z][a-zA-Z0-9-_]{{2,254}}$`." + expression: `^[a-zA-Z][a-zA-Z0-9-_\\.]{{2,254}}$`." ); } @@ -225,8 +225,10 @@ mod tests { validate_identifier("Cluster ID", "fo").unwrap_err(); validate_identifier("Cluster ID", "_fo").unwrap_err(); validate_identifier("Cluster ID", "_foo").unwrap_err(); + validate_identifier("Cluster ID", ".foo.bar").unwrap_err(); validate_identifier("Cluster ID", "foo").unwrap(); validate_identifier("Cluster ID", "f-_").unwrap(); + validate_identifier("Index ID", "foo.bar").unwrap(); assert!(validate_identifier("Cluster ID", "foo!") .unwrap_err() diff --git a/quickwit/quickwit-integration-tests/src/tests/index_tests.rs b/quickwit/quickwit-integration-tests/src/tests/index_tests.rs index a68dff26477..8161009b33a 100644 --- a/quickwit/quickwit-integration-tests/src/tests/index_tests.rs +++ b/quickwit/quickwit-integration-tests/src/tests/index_tests.rs @@ -455,7 +455,7 @@ async fn test_very_large_index_name() { assert!(error.to_string().ends_with( "is invalid. Identifiers must match the following regular expression: \ - `^[a-zA-Z][a-zA-Z0-9-_]{2,254}$`..)" + `^[a-zA-Z][a-zA-Z0-9-_\\.]{2,254}$`..)" )); // Clean up