Skip to content

fix(serialization): support content-type parameters in form factories - #868

Closed
Hardik K (hardikkaurani) wants to merge 4 commits into
microsoft:mainfrom
hardikkaurani:fix/form-factories-content-type-parameters
Closed

Hardik K (hardikkaurani) wants to merge 4 commits into
microsoft:mainfrom
hardikkaurani:fix/form-factories-content-type-parameters

Conversation

@hardikkaurani

Copy link
Copy Markdown
Contributor

Summary

FormParseNodeFactory.get_root_parse_node() and FormSerializationWriterFactory.get_serialization_writer() previously used strict equality against application/x-www-form-urlencoded (valid_content_type.casefold() != content_type.casefold()).

As a result, both factories rejected valid content types that contain MIME parameters (such as application/x-www-form-urlencoded; charset=utf-8 or application/x-www-form-urlencoded; charset=UTF-8) or whitespace around the parameter separator with a TypeError.

Per RFC 2045 §5.1, media types and subtypes are parameter-agnostic for type identification. This change brings the Python form serialization factories to parity with the implementations in Kiota Java, .NET, TypeScript, and Go.

Changes

  • Commit 1 (fix): Updated FormParseNodeFactory.get_root_parse_node to strip MIME parameters and surrounding whitespace (content_type.split(";")[0].strip().casefold()) before comparing against valid_content_type.casefold().
  • Commit 2 (test): Added parameterized tests to test_form_parse_node_factory.py asserting acceptance of content types with MIME parameters (charset=utf-8, charset=UTF-8), whitespace variants, and case variations, while continuing to reject delimiter-only and invalid content types.
  • Commit 3 (fix): Updated FormSerializationWriterFactory.get_serialization_writer to strip MIME parameters and surrounding whitespace before comparing against valid_content_type.casefold().
  • Commit 4 (test): Added parameterized tests to test_form_serialization_writer_factory.py asserting acceptance of content types with MIME parameters, whitespace variants, and case variations, while continuing to reject delimiter-only and invalid content types.

Verification

  • cd packages/serialization/form
  • pytest: 149/149 passed (100% test pass rate).
  • mypy kiota_serialization_form: no issues found in 6 source files.
  • pylint kiota_serialization_form --disable=W --rcfile=.pylintrc: 10.00/10.
  • yapf -dr kiota_serialization_form: clean.
  • cd packages/bundle && pytest: 2/2 passed.

…actory

Strip MIME parameters and surrounding whitespace from the content-type argument before comparing against the valid content type in FormParseNodeFactory.get_root_parse_node, aligning with RFC 2045 §5.1.

Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…ntent-type parameters

Add parameterized tests verifying that FormParseNodeFactory properly accepts content types with MIME parameters and case variations while continuing to reject delimiter-only and invalid content types.

Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…ionWriterFactory

Strip MIME parameters and surrounding whitespace from the content-type argument before comparing against the valid content type in FormSerializationWriterFactory.get_serialization_writer, aligning with RFC 2045 §5.1.

Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…Factory content-type parameters

Add parameterized tests verifying that FormSerializationWriterFactory properly accepts content types with MIME parameters and case variations while continuing to reject delimiter-only and invalid content types.

Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
@hardikkaurani
Hardik K (hardikkaurani) requested a review from a team as a code owner November 7, 2026 06:26
Copilot AI balanced review requested due to automatic review settings November 7, 2026 06:26

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@sonarqubecloud

sonarqubecloud Bot commented Nov 7, 2026

Copy link
Copy Markdown

@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Hi Vincent Biret (@baywet),

Opening this PR to ensure FormParseNodeFactory and FormSerializationWriterFactory properly accept content types containing MIME parameters (e.g. application/x-www-form-urlencoded; charset=utf-8) or whitespace around the parameter separator.

Previously, both factories performed strict equality checks on content_type.casefold(), rejecting valid parameter-bearing media types with a TypeError. This change strips MIME parameters before validation per RFC 2045 §5.1, aligning Python form serialization with the other Kiota language SDKs.

Parameterized regression tests covering charset parameters, whitespace variations, and delimiter edge cases have been added. All 149 package tests, mypy, and pylint (10/10) pass cleanly.

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

No active review issues are reported for the changes enabling Python form factories to accept content types with MIME parameters.

No open issues 🎉

Review effort: Balanced

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

No active review issues were identified for the content-type normalization changes.

No open issues 🎉

Review effort: Balanced

@baywet

Copy link
Copy Markdown
Member

Hi Hardik K (@hardikkaurani), thank you for your contribution!

This pull request is being closed automatically because you currently have more than 10 open pull requests across the Kiota repositories. Reviewing takes time, and having this many pull requests open at once overwhelms the reviewers. Please avoid having more than 10 open pull requests at any given time.

To move forward, you can either:

  • Wait for your existing pull requests to get merged, and make sure to respond timely to any feedback to help move things along.
  • Close older pull requests that are no longer relevant, and then re-open this one.

auto-merge was automatically disabled November 11, 2026 14:52

Pull request was closed

@github-project-automation github-project-automation Bot moved this from In Progress 🚧 to Done ✔️ in Kiota Nov 11, 2026
@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Hi Vincent,

Thank you for letting me know, and I appreciate your continued guidance and patience.

I'm sorry for having more than 10 open pull requests across the Kiota repositories and for creating additional review overhead. I understand that reviewing so many PRs at once takes considerable time from the maintainers.

I'll focus on getting my existing PRs merged, respond promptly to review feedback, and close any older PRs that are no longer relevant. I'll make sure to keep my open PR count below 10 before submitting any new ones.

Apologies again for the inconvenience, and thank you for the opportunity to contribute to Kiota. I appreciate your understanding.

@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Hi Vincent Biret (@baywet), I currently have fewer than 10 open pull requests across the Kiota repositories. Would it be okay if I reopened this PR?

@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Hi Vincent Biret (@baywet), GitHub doesn't allow me to reopen this PR from my end since it was closed by a maintainer. Whenever there's room under the 10-PR limit, could you please reopen it on your side? Thanks!

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

Labels

None yet

Projects

Status: Done ✔️

Development

Successfully merging this pull request may close these issues.

3 participants