Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correctly serialize None in a list #386

Merged
merged 2 commits into from
Oct 16, 2024

Conversation

Acurisu
Copy link
Contributor

@Acurisu Acurisu commented Oct 16, 2024

Overview

We currently have two issues:

  1. We don't support None inside lists.
  2. We convert None to 'null' when there is no key. Simply fixing issue 1 would result in ['null', 'null'] instead of [null, null].

The first issue arises when fetching, for example, all graph site pages of a site and attempting to serialize them. A specific case involves expanding canvasLayout and receiving a page without a canvasLayout, which results in pinnedItems containing [None, None, None].

Although whether this response is correct is another question, the serialization should not raise an exception in this scenario but should handle it appropriately.

Testing Instructions

I have added relevant tests. Simply run pytest to verify the fix. Running the same tests without my changes will result in an exception.

@Acurisu Acurisu requested a review from a team as a code owner October 16, 2024 14:22
@andrueastman
Copy link
Member

Thanks for opening this @Acurisu

If we were to include this change, it would however not trigger a release. Any chance you can include/modify commits to follow the conventions here
https://github.com/microsoft/kiota-python/blob/main/CONTRIBUTING.md#commit-message-format

@Acurisu
Copy link
Contributor Author

Acurisu commented Oct 16, 2024

Thanks for opening this @Acurisu

If we were to include this change, it would however not trigger a release. Any chance you can include/modify commits to follow the conventions here https://github.com/microsoft/kiota-python/blob/main/CONTRIBUTING.md#commit-message-format

Yes of course. Sorry, thought I opened this PR as a draft.

@Acurisu Acurisu force-pushed the json_serialize_none_in_list branch from 7ed3636 to fd975c2 Compare October 16, 2024 14:41
@Acurisu
Copy link
Contributor Author

Acurisu commented Oct 16, 2024

Done. I hope this works out.

Copy link

Copy link
Member

@andrueastman andrueastman left a comment

Choose a reason for hiding this comment

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

Thanks again for the contribution @Acurisu

@andrueastman andrueastman merged commit 0a02628 into microsoft:main Oct 16, 2024
47 checks passed
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.

2 participants