Skip to content

Handle map-style query parameters with None values#666

Open
bkoelman wants to merge 2 commits into
microsoft:mainfrom
bkoelman:fix/map-query-parameters
Open

Handle map-style query parameters with None values#666
bkoelman wants to merge 2 commits into
microsoft:mainfrom
bkoelman:fix/map-query-parameters

Conversation

@bkoelman

Copy link
Copy Markdown

Contributes to microsoft/kiota#3800.

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.

@bkoelman
bkoelman force-pushed the fix/map-query-parameters branch from b78a3c3 to ea0c6e2 Compare July 23, 2026 00:12
@bkoelman
bkoelman marked this pull request as ready for review July 23, 2026 00:24
@bkoelman
bkoelman requested a review from a team as a code owner July 23, 2026 00:24
@baywet
baywet requested a review from Copilot July 23, 2026 13:39
baywet
baywet previously approved these changes Jul 23, 2026

@baywet baywet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution!

@github-project-automation github-project-automation Bot moved this to In Progress 🚧 in Kiota Jul 23, 2026
@baywet

baywet commented Jul 23, 2026

Copy link
Copy Markdown
Member

@bkoelman can you fix the formatting as reported by this action run please? after that I think we'd be good to go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 dict values passed into URI template expansion by dropping None entries and recursively sanitizing remaining values.
  • Add new unit tests covering map query expansion behavior (including omission of None values and preservation of empty strings), plus a dataclass-based set_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.

Comment on lines +313 to +315
# 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.
bkoelman and others added 2 commits July 24, 2026 03:09
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>
@sonarqubecloud

Copy link
Copy Markdown

@bkoelman

Copy link
Copy Markdown
Author

pushed fixes and rebased on latest main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress 🚧

Development

Successfully merging this pull request may close these issues.

3 participants