fix: Exclude None/null values in request data #3060
+2
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please describe the purpose of this pull request.
Prevents sending
nullvalues to OpenAI-compatible endpoints. Optional parameters should be excluded entirely - don't rely on endpoints to handlenullvalues identically.Fixes a 400 error I was having when using https://synthetic.new as my OpenAI-proxy, specifically when attempting to run summarization.
How to test
Run summarization and verify that the request made no longer contains
{..., "tools": null, "tool_choice": null}Have you tested this PR?
Only by manually sending requests to my chosen endpoint to verify what the issue was.
Summarization API response with nulls:
Details
``` Error code: 400, Response JSON: {'error': '[object Object] failed the following checks:\n' '[object Object] failed the following checks:\n' 'null is not an array\n' 'null failed the following checks:\n' 'null failed the following checks:\n' 'null is not equal to auto\n' 'null failed the following checks:\n' 'null is not equal to none\n' 'null is not equal to required\n' 'null is null\n' "missing key 'stream'\n" '[object Object] failed the following checks:\n' 'null is not an array\n' 'null failed the following checks:\n' 'null failed the following checks:\n' 'null is not equal to auto\n' 'null failed the following checks:\n' 'null is not equal to none\n' 'null is not equal to required\n' 'null is null'} ```
Summarization API response without nulls:
Details
``` Code: 200, Response JSON: {'choices': [...], 'created': 1762445699, 'id': '6c8e5475-33bb-4679-8158-d350262d8fd6', 'model': 'accounts/fireworks/models/gpt-oss-120b', 'object': 'chat.completion', 'usage': {...}} ```