Fix Contact 'email' property filtered due to 'Emails' HubSpot type #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses an issue where the
email
property was being incorrectly filtered out due to a conflict with theEmails
HubSpot type. This was causing asales-email-read
scope error when attempting to access$contact->email
, as the code was inadvertently trying to access the$contact->emails
associated type instead.Changes:
isAllowedProperty
method to centralize property filtering logicfill
and__set
methods to useisAllowedProperty
email
property while maintaining filtering for other HubSpot typesThis fix ensures that:
email
property is correctly retained and accessibleEmails
associated type when simply trying to get the email property from aContact
sales-email-read
scope error is avoided foremail
property accessThe original intent of filtering out most HubSpot types is maintained, while solving this specific edge case.
This change should resolve issues for users who were encountering unexpected scope errors when working with contact email addresses.
Bug Demonstration
Currently, if you run this code:
email
is not defined. This is becauseemail
when pluralized (src/Api/Model.php line 85) is a HubSpot associated type ofContact
. It also triggers an attempt to download the Contact's associated Emails, which can lead to unexpected behavior and potentialsales-email-read
scope errors.