Handle map-style query parameters with None values#666
Conversation
b78a3c3 to
ea0c6e2
Compare
|
@bkoelman can you fix the formatting as reported by this action run please? after that I think we'd be good to go |
There was a problem hiding this comment.
Pull request overview
This PR updates RequestInformation URL building to safely handle map/dictionary-style query parameters whose values include None, aligning behavior with RFC 6570 “undefined” semantics and preventing StdUriTemplate from raising when encountering None inside map expansions.
Changes:
- Sanitize
dictvalues passed into URI template expansion by droppingNoneentries and recursively sanitizing remaining values. - Add new unit tests covering map query expansion behavior (including omission of
Nonevalues and preservation of empty strings), plus a dataclass-basedset_query_string_parameters_from_raw_object()path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/abstractions/kiota_abstractions/request_information.py | Adds dict/map sanitization to omit None entries before URI template expansion. |
| packages/abstractions/tests/test_request_information.py | Adds test coverage for RFC 6570 map-style query parameter expansion and edge cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Map-style query parameter: drop None entries per RFC 6570 §2.3 "undefined" | ||
| # semantics, then normalise remaining values. StdUriTemplate raises ValueError | ||
| # when it encounters None inside a map, so we strip them here. |
Dict values used as map/dictionary query parameters (from an OpenAPI `type: object` with `additionalProperties` field) are now sanitized before being passed to StdUriTemplate. None values are silently dropped per RFC 6570 §2.3 "undefined" semantics, preventing a ValueError when StdUriTemplate tries to convert None to a string. An empty string must be set explicitly to send `key=`. Adds seven test cases covering map expansion, None-value omission, empty-string inclusion, empty dicts, all-None dicts, mixed scalar+map parameters, and the set_query_string_parameters_from_raw_object() path. Co-authored-by: Cursor <cursoragent@cursor.com>
…ery parameters Address build check feedback by fixing yapf formatting in request_information.py and isort ordering in date_utils.py. Also ignore None keys when sanitizing map query parameters. Co-authored-by: Cursor <cursoragent@cursor.com>
ea0c6e2 to
79db213
Compare
|
|
pushed fixes and rebased on latest main |



Contributes to microsoft/kiota#3800.
Dict values used as map/dictionary query parameters (from an OpenAPI
type: objectwithadditionalPropertiesfield) are now sanitized before being passed to StdUriTemplate. None values are silently dropped per RFC 6570 §2.3 "undefined" semantics, preventing a ValueError when StdUriTemplate tries to convert None to a string. An empty string must be set explicitly to sendkey=.Adds seven test cases covering map expansion, None-value omission, empty-string inclusion, empty dicts, all-None dicts, mixed scalar+map parameters, and the set_query_string_parameters_from_raw_object() path.