Skip to content

fix(database): parse new schema property types and skip unknown ones - #114

Merged
brd6 merged 7 commits into
mainfrom
fix/property-object-fallback
Oct 23, 2026
Merged

brd6 merged 7 commits into
mainfrom
fix/property-object-fallback

Conversation

@brd6

@brd6 brd6 commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Description

Adds schema property objects for the three types Notion returns in database and data source schemas that the SDK could not parse:

  • VerificationPropertyObject with an empty VerificationPropertyConfiguration;
  • UniqueIdPropertyObject with a UniqueIdPropertyConfiguration exposing getPrefix() / setPrefix();
  • ButtonPropertyObject with an empty ButtonPropertyConfiguration.

They follow the existing PlacePropertyObject and PhoneNumberPropertyObject shape.

AbstractPropertyObject::getMapClassFromType() now falls back to a new UnsupportedPropertyObject for any type without a property object class, the same way AbstractBlock falls back to UnsupportedBlock. The fallback keeps the property's id, name and type, and getRawData() returns the untouched configuration.

DataSource::toArrayForUpdate() leaves out two more kinds of property. button and verification join the computed types (created_by, created_time, last_edited_by, last_edited_time) in its private read-only list, and every UnsupportedPropertyObject is skipped. Database update payloads are unchanged.

UnsupportedPropertyObjectException is kept for backward compatibility. Nothing throws it any more, so the stale @throws tags on AbstractPropertyObject, DataSource and Database are removed.

Motivation and context

getMapClassFromType() threw UnsupportedPropertyObjectException for every schema type without a matching class. Every wiki database has a verification property, and unique_id and button are common, so DataSource::fromRawData() and Database::fromRawData() threw on those schemas. The exception failed the whole search, dataSources()->retrieve() or databases()->retrieve() result, not just the one property.

Page property values already handle all three types (VerificationPropertyValue, UniqueIdPropertyValue, ButtonPropertyValue); only the schema side was missing.

Once those schemas parse, a retrieved data source can be sent back through dataSources()->update(). The Property object reference says "Button and Verification schemas are response-only", so both join the computed types that data source updates already omit. An unsupported property has no configuration the SDK can vouch for, so it is omitted too. The Update data source properties reference says "Existing properties that you omit stay unchanged". UnsupportedBlock writes no block content back either. One trade-off: a raw array with a mistyped type passed to DataSource::setProperties() is now left out of the update instead of being rejected.

Schema shapes, checked against:

  • the Notion API reference, Property object: "verification": {} ("Its schema response has an empty verification object"), "unique_id": { "prefix": "TASK" } ("Its prefix is a string or null"), "button": {} ("A Button property has an empty button object in schema responses");
  • the official JavaScript SDK, src/api-endpoints/data-sources.ts (UniqueIdDatabasePropertyConfigResponse: unique_id: { prefix: string | null }) and src/api-endpoints/common.ts (VerificationPropertyConfigurationRequest: verification: EmptyObject, ButtonPropertyConfigurationRequest: button: EmptyObject, UniqueIdPropertyConfigurationRequest: unique_id: { prefix?: string | null }), at makenotion/notion-sdk-js@10aa976.

How has this been tested?

Local commands ran on PHP 8.3 (php:8.3-cli) at 96bb27d, the last commit before main (with #115) was merged in. The merge only touches composer.json, and vendor/bin/phpunit --no-coverage gives the same result at the merge head, 1b43231.

  • vendor/bin/phpunit --no-coverage: 310 tests, 2613 assertions, all passing.
  • New DataSourceTest::testDataSourceHydratesVerificationUniqueIdAndButtonPropertyConfigurations hydrates a data source whose schema holds verification, unique_id (prefix TASK) and button. It checks that each one maps to its class, reads the prefix, and that toArray() returns each property with the same keys and values Notion sent. Before the change it fails with UnsupportedPropertyObjectException: The given property object "verification" is unsupported.
  • New DataSourceTest::testDataSourceHydratesUnknownPropertyTypeAsUnsupportedPropertyObject hydrates a schema with an unknown future_type property. It checks the fallback class, its id, name, type and raw data, that the other properties still hydrate, and that toArrayForUpdate() leaves it out. Before the change it fails with the same exception.
  • DataSourceTest::testUpdateSerializationOmitsReadOnlyPropertyConfigurations now also covers verification and button. It failed with Failed asserting that an array does not have the key 'Verification' before they were treated as read-only.
  • DataSourceTest::testSetPropertiesRejectsRawArrayWithUnknownType asserted the old exception. It is now testSetPropertiesFallsBackToUnsupportedPropertyObjectForUnknownType and asserts the fallback.
  • vendor/bin/phpstan analyse, vendor/bin/psalm --no-cache, vendor/bin/phpcs and vendor/bin/parallel-lint src tests report no errors.
  • php -l on every changed file under PHP 7.4 reports no syntax errors.
  • CI on this pull request (run 39958783080, head 1b43231): all 21 jobs pass, including Coding standards, Static analysis and Code coverage on PHP 8.1, and Unit tests on PHP 7.4, 8.0 and 8.1 across Ubuntu, macOS and Windows with lowest and highest dependencies.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

PR checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING.md document.
  • I have added tests to cover my changes.

brd6 added 2 commits October 23, 2026 12:17
Notion returns verification, unique_id and button entries in database and
data source schemas. Without a property object for them, hydrating any
database or data source that holds one threw, which failed whole search
and retrieve results.
…bject

A schema property type the SDK does not model yet now hydrates as an
UnsupportedPropertyObject that keeps its id, name, type and raw data,
like UnsupportedBlock does for blocks. One new Notion property type no
longer breaks parsing of a whole database, data source or search result.

UnsupportedPropertyObjectException stays available for backward
compatibility but is no longer thrown.
brd6 added 3 commits October 23, 2026 12:34
…pdates

Notion's property reference describes Button and Verification schemas as
response-only, and the API cannot create a Verification property through
a schema write. Treat both like the other computed configurations so a
retrieved data source can be sent back unchanged.
An UnsupportedPropertyObject holds no writable configuration, so sending
it back produced an entry with only id, name and type. Notion keeps
existing properties that an update omits, so leaving it out is the only
write that cannot change or reject the schema, matching how
UnsupportedBlock writes no block content.
Database::toArrayForUpdate() still sends the property schema on Notion
versions before 2025-09-03, which is the SDK default, but it never
filtered computed or unsupported configurations the way data sources
do. Move the read-only types onto the property objects as isWritable(),
with UnsupportedPropertyObject never writable, and use it for both data
source and database updates.
@brd6 brd6 changed the title fix(database): parse verification, unique ID and button properties fix(database): parse new schema property types and skip unknown ones Oct 23, 2026
brd6 added 2 commits October 23, 2026 13:03
This reverts commit d6bc397.

The public isWritable() it added reported writable created and edited
columns as read-only, and returned true on a freshly built property
object whose type is not set yet. Its Database filter also turned typed
created_time and last_edited_time writes on Notion versions before
2025-09-03 into silent no-ops. Data source updates keep their private
read-only list and the UnsupportedPropertyObject omission.
@brd6
brd6 marked this pull request as ready for review October 23, 2026 13:11
@brd6
brd6 merged commit 3e6a86d into main Oct 23, 2026
21 checks passed
@brd6
brd6 deleted the fix/property-object-fallback branch October 23, 2026 15:03
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.

1 participant