Skip to content

Commit 9370179

Browse files
authored
Merge pull request #164 from caibirdme/debug-panic
Debug panic
2 parents 780a254 + 8d126f4 commit 9370179

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/logquery/labels.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,17 @@ fn get_rest_label_pairs(
241241
let suffix = &cache_key_with_matches[start..];
242242
let pairs = suffix
243243
.split('-')
244-
.map(|s| {
244+
.filter_map(|s| {
245245
let parts = s.split('/').collect::<Vec<_>>();
246-
parser::LabelPair {
247-
label: parts[0].to_string(),
246+
if parts.len() == 3 {
247+
Some(parser::LabelPair {
248+
label: parts[0].to_string(),
248249
op: str_to_operator(parts[1].chars().next().unwrap()),
249-
value: parts[2].to_string(),
250+
value: parts[2].to_string(),
251+
})
252+
} else {
253+
debug!("invalid label pair, using_key: {}, cache_key_with_matches: {}, suffix: {}", using_key, cache_key_with_matches, suffix);
254+
None
250255
}
251256
})
252257
.collect();
@@ -390,6 +395,7 @@ mod tests {
390395
#[test]
391396
fn test_get_rest_label_pairs() {
392397
let test_cases = vec![
398+
("cc:series:", "cc:series:", vec![]),
393399
(
394400
"cc:series:",
395401
"cc:series:-k1/0/v1",

0 commit comments

Comments
 (0)