mariosimao / notion-sdk-php

A complete Notion SDK for PHP developers.
https://mariosimao.github.io/notion-sdk-php/
MIT License
150 stars 24 forks source link

Archived users causing UserType fatal error #311

Open benjwalker opened 10 months ago

benjwalker commented 10 months ago

When running the below query, if the returned page is assigned to a user that's been archived it throws a fatal error "Fatal error: Uncaught ValueError: "0" is not a valid backing value for enum "Notion\Users\UserType"".

$notion = Notion::create(NOTION_SECRET);
$database = $notion->databases()->find(NOTION_WEB_TASKS_DATABASE);

$query = Query::create()
    ->changeFilter(
        CompoundFilter::and(
            TextFilter::property("Name")->contains($title),
        )
    )
    ->addSort(Sort::property("Name")->ascending())
    ->changePageSize(20);

$task = $notion->databases()->query($database, $query)->pages[0];
mariosimao commented 8 months ago

Hello @benjwalker I am sorry for the late reply.

Unfortunately, I do not have a Notion Pro plan to add multiple users and reproduce. Could you past the entire exception stack trace so I could understand better what is happening?

benjwalker commented 6 months ago

Apologies for the delay also, hadn't actually received the error in a while, but just triggered it, full error I get from my script is below...

Fatal error: Uncaught ValueError: "0" is not a valid backing value for enum "Notion\Users\UserType" in /home/wearearise/public_html/subdomains/qb/vendor/mariosimao/notion-sdk-php/src/Users/User.php:42 Stack trace: #0 /home/wearearise/public_html/subdomains/qb/vendor/mariosimao/notion-sdk-php/src/Users/User.php(42): Notion\Users\UserType::from(NULL) #1 /home/wearearise/public_html/subdomains/qb/vendor/mariosimao/notion-sdk-php/src/Pages/Properties/People.php(42): Notion\Users\User::fromArray(Array) #2 [internal function]: Notion\Pages\Properties\People::Notion\Pages\Properties\{closure}(Array) #3 /home/wearearise/public_html/subdomains/qb/vendor/mariosimao/notion-sdk-php/src/Pages/Properties/People.php(44): array_map(Object(Closure), Array) #4 /home/wearearise/public_html/subdomains/qb/vendor/mariosimao/notion-sdk-php/src/Pages/Properties/PropertyFactory.php(26): Notion\Pages\Properties\People::fromArray(Array) #5 /home/wearearise/public_html/subdomains/qb/vendor/mariosimao/notion-sdk-php/src/Pages/Page.php(93): Notion\Pages\Properties\PropertyFactory::fromArray(Array) #6 /home/wearearise/public_html/subdomains/qb/vendor/mariosimao/notion-sdk-php/src/Databases/Query/Result.php(34): Notion\Pages\Page::fromArray(Array) #7 [internal function]: Notion\Databases\Query\Result::Notion\Databases\Query\{closure}(Array) #8 /home/wearearise/public_html/subdomains/qb/vendor/mariosimao/notion-sdk-php/src/Databases/Query/Result.php(36): array_map(Object(Closure), Array) #9 /home/wearearise/public_html/subdomains/qb/vendor/mariosimao/notion-sdk-php/src/Databases/Client.php(99): Notion\Databases\Query\Result::fromArray(Array) #10 /home/wearearise/public_html/subdomains/qb/php/classes/quickbooks.php(416): Notion\Databases\Client->query(Object(Notion\Databases\Database), Object(Notion\Databases\Query)) #11 /home/wearearise/public_html/subdomains/qb/php/classes/router.php(85): Quickbooks->update() #12 /home/wearearise/public_html/subdomains/qb/index.php(7): Router->route(Array) #13 {main} thrown in /home/wearearise/public_html/subdomains/qb/vendor/mariosimao/notion-sdk-php/src/Users/User.php on line 42