Skip to content

fix(serialization-form): preserve whitespace in string values - #791

Merged
Vincent Biret (baywet) merged 2 commits into
microsoft:mainfrom
rksharma-owg:codex/fix-form-string-whitespace
Oct 13, 2026
Merged

Vincent Biret (baywet) merged 2 commits into
microsoft:mainfrom
rksharma-owg:codex/fix-form-string-whitespace

Conversation

@rksharma-owg

Copy link
Copy Markdown
Contributor

Fixes #789.

Form string serialization trims leading and trailing whitespace, changing the supplied payload.

write_str_value calls strip on the value before percent-encoding it. Encode the original string value. Existing key normalization and omission of None/empty strings remain unchanged.

Added standard-library parse_qs regressions for surrounding whitespace, whitespace-only values and Unicode whitespace; retained plain-value and None/empty omission controls.

Validation: five new cases fail before the correction; all 63 form tests pass locally after it. YAPF, isort, Pylint and mypy pass. Pylint prints the existing suggestion-mode configuration diagnostic (exit 0), also reproduced on unchanged main and upstream CI.

Fork validation: run 38161550435, tested commit 3dc5580abe640436b521e0449fc0c4ace9834755, target 79370e7ee8171a42abc828376dcbc331c27623e8, fork-only workflow revision c517af083bb74af2a9877dc97eef434f8e014d70.

All 46 jobs for this commit passed: eight packages across Python 3.10–3.14 with upstream formatting/import/Pylint/mypy/pytest commands, generated-code type checks on all five versions, and CodeQL. Each form run passed all 63 tests with no skips. CodeQL reported zero findings. Upstream import normalization is reproduced; the changed form package additionally needs no normalization. The validation workflow is separate from this PR.

The unchanged target passed upstream build run 37963997486; its form suite ran 55 tests successfully on each supported Python version.

@rksharma-owg
RKS (rksharma-owg) requested a review from a team as a code owner October 11, 2026 17:59
@baywet
Vincent Biret (baywet) requested a balanced review from Copilot October 13, 2026 13:24

@baywet Vincent Biret (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!

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.

🟢 Approval recommended

The focused implementation matches the documented behavior and has appropriate regression coverage.

0 open findings

What changed in this PR

Preserves whitespace in form-serialized string values without changing key normalization or empty-value omission.

Changes:

  • Encodes original string values without stripping whitespace.
  • Adds regression tests for whitespace, Unicode, and omitted values.
File Description
form_serialization_writer.py Removes value trimming before encoding.
test_form_serialization_writer.py Covers whitespace preservation and omission behavior.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI balanced review requested due to automatic review settings October 13, 2026 13:35
@sonarqubecloud

Copy link
Copy Markdown

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.

🟢 Approval recommended

The focused implementation correctly preserves payload data and is covered by appropriate regressions.

0 open findings

🧠 Review effort: Balanced

@baywet
Vincent Biret (baywet) merged commit 06e7026 into microsoft:main Oct 13, 2026
104 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress 🚧 to Done ✔️ in Kiota Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Form serialization strips whitespace from string values

3 participants