feat(generated): Add new classes and fields for API key validation and dsync tokens#378
Conversation
Greptile SummaryThis auto-generated PR adds new resource classes for API key validation, dsync token events, and membership-with-user shapes, while also extending several existing classes with
Confidence Score: 1/5Not safe to merge — two P0 TypeErrors will break API key event deserialization at runtime. Two P0 bugs (TypeError in
Important Files Changed
|
| object: $data['object'] ?? 'api_key', | ||
| id: $data['id'], | ||
| owner: ApiKeyCreatedDataOwner::fromArray($data['owner']), | ||
| owner: $data['owner'], |
There was a problem hiding this comment.
TypeError: raw array passed to typed
ApiKeyCreatedDataOwner property
$data['owner'] is a plain array, but the constructor declares owner as ApiKeyCreatedDataOwner. PHP will throw a TypeError at runtime on any call to ApiKeyCreatedData::fromArray(). The diff removed the ApiKeyCreatedDataOwner::fromArray($data['owner']) call that was there before.
| owner: $data['owner'], | |
| owner: ApiKeyCreatedDataOwner::fromArray($data['owner']), |
| object: $data['object'] ?? 'api_key', | ||
| id: $data['id'], | ||
| owner: ApiKeyRevokedDataOwner::fromArray($data['owner']), | ||
| owner: $data['owner'], |
There was a problem hiding this comment.
TypeError: raw array passed to typed
ApiKeyRevokedDataOwner property
Same issue as ApiKeyCreatedData: $data['owner'] is an array but the constructor expects ApiKeyRevokedDataOwner. Every call to ApiKeyRevokedData::fromArray() will throw a TypeError.
| owner: $data['owner'], | |
| owner: ApiKeyRevokedDataOwner::fromArray($data['owner']), |
| createdAt: new \DateTimeImmutable($data['created_at']), | ||
| updatedAt: new \DateTimeImmutable($data['updated_at']), | ||
| role: SlimRole::fromArray($data['role']), | ||
| user: User::fromArray($data['user']), |
There was a problem hiding this comment.
Missing null guard on required
user key
$data['user'] is accessed without a null/isset check. If any API response omits the user field (e.g. older SDK responses or partial payloads), this will throw an Undefined array key "user" error. The same pattern appears in UserOrganizationMembership.php and UserOrganizationMembershipBaseWithUser.php.
| object: $data['object'] ?? 'api_key', | ||
| id: $data['id'], | ||
| owner: ApiKeyCreatedDataOwner::fromArray($data['owner']), | ||
| owner: $data['owner'], |
There was a problem hiding this comment.
🔴 ApiKeyCreatedData::fromArray passes raw array to typed ApiKeyCreatedDataOwner parameter
The fromArray method at line 44 passes $data['owner'] (a raw associative array from JSON decode) directly to the constructor, but the owner parameter is typed as ApiKeyCreatedDataOwner (line 20). With declare(strict_types=1) at the top of the file, this will throw a TypeError at runtime: "Cannot pass value of type array to parameter $owner of type ApiKeyCreatedDataOwner". The previous code correctly called ApiKeyCreatedDataOwner::fromArray($data['owner']). The same issue exists in toArray() at line 59, where $this->owner is output directly instead of calling $this->owner->toArray().
| owner: $data['owner'], | |
| owner: ApiKeyCreatedDataOwner::fromArray($data['owner']), |
Was this helpful? React with 👍 or 👎 to provide feedback.
| 'object' => $this->object, | ||
| 'id' => $this->id, | ||
| 'owner' => $this->owner->toArray(), | ||
| 'owner' => $this->owner, |
There was a problem hiding this comment.
🔴 ApiKeyCreatedData::toArray outputs owner object directly instead of calling toArray()
At line 59, toArray() outputs 'owner' => $this->owner directly. Since $this->owner is typed as ApiKeyCreatedDataOwner, this should be $this->owner->toArray() to properly serialize the object to an array, consistent with the pattern used in all other resource classes. If BUG-0001 is fixed (so $this->owner is a proper ApiKeyCreatedDataOwner object), this line will put an object into the array instead of a serialized array representation.
| 'owner' => $this->owner, | |
| 'owner' => $this->owner->toArray(), |
Was this helpful? React with 👍 or 👎 to provide feedback.
| object: $data['object'] ?? 'api_key', | ||
| id: $data['id'], | ||
| owner: ApiKeyRevokedDataOwner::fromArray($data['owner']), | ||
| owner: $data['owner'], |
There was a problem hiding this comment.
🔴 ApiKeyRevokedData::fromArray passes raw array to typed ApiKeyRevokedDataOwner parameter
Identical issue to ApiKeyCreatedData: line 44 passes $data['owner'] (a raw array) to the constructor, but the owner parameter is typed as ApiKeyRevokedDataOwner (lib/Resource/ApiKeyRevokedData.php:20). With declare(strict_types=1), this throws a TypeError at runtime. The previous code correctly called ApiKeyRevokedDataOwner::fromArray($data['owner']).
| owner: $data['owner'], | |
| owner: ApiKeyRevokedDataOwner::fromArray($data['owner']), |
Was this helpful? React with 👍 or 👎 to provide feedback.
| 'object' => $this->object, | ||
| 'id' => $this->id, | ||
| 'owner' => $this->owner->toArray(), | ||
| 'owner' => $this->owner, |
There was a problem hiding this comment.
🔴 ApiKeyRevokedData::toArray outputs owner object directly instead of calling toArray()
At line 59, toArray() outputs 'owner' => $this->owner directly instead of $this->owner->toArray(), identical to the issue in ApiKeyCreatedData. This will produce incorrect serialization output.
| 'owner' => $this->owner, | |
| 'owner' => $this->owner->toArray(), |
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
ApiKeyValidationResponseApiKey,ApiKeyValidationResponseApiKeyOwner,DsyncTokenCreated,DsyncTokenCreatedData,DsyncTokenDeleted,DsyncTokenDeletedData,UserOrganizationMembershipBaseWithUsernamefield added toDirectoryUser,DirectoryUserWithGroups,DsyncUserUpdatedData, andProfileclassesuserfield added toOrganizationMembershipandUserOrganizationMembershipclassesApiKeyValidationResponse.apiKeyfield type changed fromApiKeytoApiKeyValidationResponseApiKey(more specific type for response context)EventContextActorSourceenum now includesAdminPortalcaselistMembershipsForResourceByExternalIdandlistMembershipsForResourcenow returnUserOrganizationMembershipBaseWithUserinstead ofUserOrganizationMembershipBaseListDatagroupsfield inDirectoryUserWithGroupsrecommending migration to List Directory Groups endpointTriggered by workos/openapi-spec@91fc76a