Skip to content

Commit

Permalink
fix: add validation when json format has unstructured flag enabled (A…
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagogcampos authored Sep 5, 2024
1 parent abbde01 commit 4741624
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/arroyo-rpc/src/api_types/connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,16 @@ impl ConnectionSchema {
bail!("raw_string format requires a schema with a single field called `value` of type TEXT");
}
}
Some(Format::Json(json_format)) => {
if json_format.unstructured
&& (self.fields.len() != 1
|| self.fields.first().unwrap().field_type.r#type
!= FieldType::Primitive(PrimitiveType::Json)
|| self.fields.first().unwrap().field_name != "value")
{
bail!("json format with unstructured flag enabled requires a schema with a single field called `value` of type JSON");
}
}
_ => {
// Right now only RawString has checks, but we may add checks for other formats in the future
}
Expand Down

0 comments on commit 4741624

Please sign in to comment.