Validate label names

This commit is contained in:
2026-02-21 13:53:30 -08:00
parent 70d9dfc173
commit 8ab4ea53ec
11 changed files with 318 additions and 63 deletions

View File

@@ -1,5 +1,5 @@
use jsonpath_rust::JsonPath;
use pile_config::{ConfigToml, DatasetFts};
use pile_config::{ConfigToml, DatasetFts, Label};
use serde_json::Value;
use std::{path::PathBuf, sync::LazyLock};
use tantivy::{
@@ -106,7 +106,7 @@ impl DbFtsIndex {
pub fn get_field(
&self,
json: &Value,
field_name: &str,
field_name: &Label,
) -> Result<Option<String>, std::io::Error> {
let field = match self.cfg.schema.get(field_name) {
Some(x) => x,
@@ -124,7 +124,7 @@ impl DbFtsIndex {
warn!(
message = "Path returned more than one value, this is not supported. Skipping.",
?path,
field = field_name
field = field_name.to_string()
);
continue;
}
@@ -139,7 +139,7 @@ impl DbFtsIndex {
warn!(
message = "Invalid path, skipping",
?path,
field = field_name,
field = field_name.to_string(),
?error
);
continue;
@@ -150,7 +150,7 @@ impl DbFtsIndex {
Value::Null => {
trace!(
message = "Skipping field, is null",
field = field_name,
field = field_name.to_string(),
path,
value = ?val
);
@@ -174,7 +174,7 @@ impl DbFtsIndex {
} else if x.len() > 1 {
debug!(
message = "Skipping field, is array with more than one element",
field = field_name,
field = field_name.to_string(),
path,
value = ?val
);
@@ -182,7 +182,7 @@ impl DbFtsIndex {
} else {
debug!(
message = "Skipping field, is empty array",
field = field_name,
field = field_name.to_string(),
path,
value = ?val
);
@@ -192,7 +192,7 @@ impl DbFtsIndex {
Value::Null => {
trace!(
message = "Skipping field, is null",
field = field_name,
field = field_name.to_string(),
path,
value = ?val
);
@@ -201,7 +201,7 @@ impl DbFtsIndex {
Value::Object(_) => {
trace!(
message = "Skipping field, is object",
field = field_name,
field = field_name.to_string(),
path,
value = ?val
);