Skip to content

Fix bind_params_to_func silently accepting None for required parameters - #1225

Merged
dapr-bot merged 14 commits into
dapr:mainfrom
magic-peach:fix/bind-params-silently-accepts-none-for-required-args
Oct 15, 2026
Merged

dapr-bot merged 14 commits into
dapr:mainfrom
magic-peach:fix/bind-params-silently-accepts-none-for-required-args

Conversation

@magic-peach

Copy link
Copy Markdown
Contributor

Description

_coerce_and_validate in _conversation_helpers.py's bind_params_to_func silently accepted None for a required (non-Optional) parameter, either coercing it to the literal string 'None' or passing it through raw to crash downstream with an opaque AttributeError. Some Optional[str] = None cases were also affected depending on Union-member iteration order.

This adds an explicit check that raises a clear ToolArgumentError when None is passed for a required parameter, instead of coercing or silently passing it through.

Issue reference

Please reference the issue this PR will close: #[issue number]

N/A, self-discovered while auditing the Conversation API's tool-call argument binding, no existing issue filed.

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
@magic-peach
magic-peach requested review from a team as code owners September 20, 2026 14:26

@CasperGN CasperGN left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

I checked the case I was most worried about: optional parameters still accept None. The _is_union branch in _coerce_and_validate handles Optional[T] and returns None before the new if value is None guard is reached, and test_none_still_allowed_for_optional pins that. The guard only applies to non-Union types, which is the intent. Dropping or value is None from the dataclass branch is consistent, since the guard now catches it earlier.

One thing worth flagging for release notes: this is a visible behaviour change, not just a hardening. Models do pass explicit null for required parameters, and those calls previously bound successfully and failed later inside the tool body with an unrelated error. They now fail at bind time with a clear message. That is the better outcome, but callers relying on the old tolerance will see new ToolArgumentErrors.

@CasperGN CasperGN self-assigned this Oct 12, 2026
@sicoyle sicoyle added backport release-1.19 automerge allows dapr bot to merge a PR after tests pass labels Oct 12, 2026
@dapr-bot
dapr-bot enabled auto-merge October 13, 2026 21:28
@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.96%. Comparing base (1ae907d) to head (f884ea9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1225   +/-   ##
=======================================
  Coverage   86.96%   86.96%           
=======================================
  Files         163      163           
  Lines       12987    12989    +2     
=======================================
+ Hits        11294    11296    +2     
  Misses       1693     1693           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dapr-bot
dapr-bot added this pull request to the merge queue Oct 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 15, 2026
@dapr-bot
dapr-bot added this pull request to the merge queue Oct 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 15, 2026
@dapr-bot
dapr-bot added this pull request to the merge queue Oct 15, 2026
Merged via the queue into dapr:main with commit 27f1158 Oct 15, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge allows dapr bot to merge a PR after tests pass autoupdate backport release-1.19

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants