Skip to content

fix: allow setting properties to null #427

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

Merged
merged 2 commits into from
Mar 1, 2025

Conversation

mzahor
Copy link
Contributor

@mzahor mzahor commented Jan 13, 2025

Description

WARNING: Not sure what is the correct target branch. This is the fix for 4.2.0, based on 4.2.0 tag in git.

In Notion API, in order to clear status/phone/email/number/url property value to whatever is default, you can send null and it works same way as with Select:

{
    "properties": {
        "Status": {"status": null}
    }
}

Currently, in version 4.2.0 which is the latest published version, this prop is not serialized when null, leading to misleading validation errors from notion api, which may look like this:

body failed validation. Fix one:
body.properties.YwcW.title should be defined, instead was `undefined`.
body.properties.YwcW.rich_text should be defined, instead was `undefined`.
body.properties.YwcW.number should be defined, instead was `undefined`.
body.properties.YwcW.url should be defined, instead was `undefined`.
body.properties.YwcW.select should be defined, instead was `undefined`.
body.properties.YwcW.multi_select should be defined, instead was `undefined`.
body.properties.YwcW.people should be defined, instead was `undefined`.
body.properties.YwcW.email should be defined, instead was `undefined`.
body.properties.YwcW.phone_number should be defined, instead was `undefined`.
body.properties.YwcW.date should be defined, instead was `undefined`.
body.properties.YwcW.checkbox should be defined, instead was `undefined`.
body.properties.YwcW.relation should be defined, instead was `undefined`.
body.properties.YwcW.files should be defined, instead was `undefined`.
body.properties.YwcW.status should be defined, instead was `undefined`.
body.properties.YwcW.id should be defined, instead was `undefined`.
body.properties.YwcW.name should be defined, instead was `undefined`.
body.properties.YwcW.start should be defined, instead was `undefined`.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Tested manually and ran unit tests

  • Reading multiple pages with props of different types (including status)
  • Reading multiple pages with props of different types (including status, null and non-null)
  • Running unit tests

Test Configuration:

  • SDK: 8.0.401

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@KoditkarVedant KoditkarVedant merged commit 2293f45 into notion-dotnet:main Mar 1, 2025
6 checks passed
@tienhtse77
Copy link

tienhtse77 commented Apr 10, 2025

Hi @KoditkarVedant, do you know when will this version be released?

@KoditkarVedant
Copy link
Contributor

@tienhtse77 I'm planning to release this by this coming weekend...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants