Skip to content

chore(tools): Treat JSON null as absent in opt argument parsing#588

Merged
JeanMertz merged 1 commit intomainfrom
prr154
Apr 28, 2026
Merged

chore(tools): Treat JSON null as absent in opt argument parsing#588
JeanMertz merged 1 commit intomainfrom
prr154

Conversation

@JeanMertz
Copy link
Copy Markdown
Collaborator

Some LLMs emit explicit null values for optional parameters that were not provided by the caller. Previously, opt would attempt to deserialize null via req, which could produce a type error instead of cleanly returning None.

The fix matches on the raw Value before delegating to req, returning Ok(None) for both a missing key and an explicit Value::Null. A dedicated test covers all three cases: explicit null, a present value, and a fully absent key.

Some LLMs emit explicit `null` values for optional parameters that were
not provided by the caller. Previously, `opt` would attempt to
deserialize `null` via `req`, which could produce a type error instead
of cleanly returning `None`.

The fix matches on the raw `Value` before delegating to `req`, returning
`Ok(None)` for both a missing key and an explicit `Value::Null`. A
dedicated test covers all three cases: explicit null, a present value,
and a fully absent key.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz JeanMertz merged commit ee95513 into main Apr 28, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant