Unverified Commit f15e808d authored by drbh's avatar drbh Committed by GitHub
Browse files

fix: reject grammars without properties (#2309)

parent 922732b2
...@@ -353,6 +353,14 @@ impl Validation { ...@@ -353,6 +353,14 @@ impl Validation {
.compile(&json) .compile(&json)
.map_err(|e| ValidationError::InvalidGrammar(e.to_string()))?; .map_err(|e| ValidationError::InvalidGrammar(e.to_string()))?;
// The schema can be valid but lack properties.
// We need properties for the grammar to be successfully parsed in Python.
// Therefore, we must check and throw an error if properties are missing.
json.get("properties")
.ok_or(ValidationError::InvalidGrammar(
"Grammar must have a 'properties' field".to_string(),
))?;
// Serialize json to string // Serialize json to string
ValidGrammar::Json( ValidGrammar::Json(
serde_json::to_string(&json) serde_json::to_string(&json)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment