From c943d9774424c3f31c1c4214da844b29c3674e8f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 13 Apr 2026 09:37:17 +0000 Subject: [PATCH] Fix null-fill for nullable params when params JSON is None/null The early return at line 273 for None/Value::Null params was skipping the null-fill loop, leaving declared nullable params absent from the map. Downstream code would then error with "parameter not provided". https://claude.ai/code/session_014oGFKL7EVg1b2cyPgt9Gne --- crates/omnigraph-compiler/src/query_input.rs | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/crates/omnigraph-compiler/src/query_input.rs b/crates/omnigraph-compiler/src/query_input.rs index 6afb730..b85decf 100644 --- a/crates/omnigraph-compiler/src/query_input.rs +++ b/crates/omnigraph-compiler/src/query_input.rs @@ -270,7 +270,15 @@ pub fn json_params_to_param_map( let mut map = ParamMap::new(); let object = match params { Some(Value::Object(object)) => object, - Some(Value::Null) | None => return Ok(map), + Some(Value::Null) | None => { + // Still fill in Literal::Null for declared nullable params. + for param in query_params { + if param.nullable { + map.insert(param.name.clone(), Literal::Null); + } + } + return Ok(map); + } Some(other) => { let message = match mode { JsonParamMode::Standard => "params must be a JSON object".to_string(), @@ -992,4 +1000,18 @@ query q($tags: [String], $days: [Date]?, $due_at: DateTime) { assert!(matches!(params.get("extra"), Some(Literal::Null))); } + + #[test] + fn nullable_params_filled_when_params_is_none() { + let query = find_named_query( + "query q($bio: String?) { match { $u: User } return { $u } }", + "q", + ) + .expect("query"); + + let params = json_params_to_param_map(None, &query.params, JsonParamMode::Standard) + .expect("None params should succeed with nullable declarations"); + + assert!(matches!(params.get("bio"), Some(Literal::Null))); + } }