Skip to content

Commit

Permalink
Merge branch 'main' into evance--add-elastic-compat-cluster-info-endp…
Browse files Browse the repository at this point in the history
…oint
  • Loading branch information
evanxg852000 authored Jun 29, 2023
2 parents f86c349 + 97fd2e9 commit b1e2d43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions quickwit/quickwit-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ pub fn validate_identifier(label: &str, value: &str) -> anyhow::Result<()> {
static IDENTIFIER_REGEX: OnceCell<Regex> = 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}}$`."
);
}

Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b1e2d43

Please sign in to comment.