Skip to content

Conversation

@klezaic
Copy link

@klezaic klezaic commented Jul 1, 2025

When Symfony's PropertyAccessor fails to get a property value, whether due to an incorrect argument provided to the method, a non-existent property, or a property with insufficient visibility, one of exceptions will be thrown:
InvalidArgumentException, AccessException, UnexpectedTypeException

Since Symfony's PropertyAccessor is used by many other bundles, and often in projects codebase directly, seeing this exception in logs doesn't immediately indicate that error occurred in Purgatory.

To improve visibility and observability when these errors occur, we are re-throwing the PropertyAccessor's exception as PropertyNotAccessibleException which is specific to the Purgatory bundle.

@klezaic klezaic self-assigned this Jul 1, 2025
@klezaic klezaic requested a review from HypeMC July 1, 2025 12:34
@codecov
Copy link

codecov bot commented Jul 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.13%. Comparing base (e0ffac7) to head (76eca5b).
⚠️ Report is 1 commits behind head on 1.x.

Additional details and impacted files
@@             Coverage Diff              @@
##                1.x     #110      +/-   ##
============================================
+ Coverage     96.97%   97.13%   +0.16%     
- Complexity      491      495       +4     
============================================
  Files            62       62              
  Lines          1454     1466      +12     
============================================
+ Hits           1410     1424      +14     
+ Misses           44       42       -2     
Flag Coverage Δ
8.1 97.13% <100.00%> (+0.16%) ⬆️
8.2 97.06% <100.00%> (+0.16%) ⬆️
8.3 97.06% <100.00%> (+0.16%) ⬆️
8.4 97.06% <100.00%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@klezaic klezaic requested a review from Brajk19 July 1, 2025 13:17
Comment on lines 38 to 42
} catch (\InvalidArgumentException|AccessException|UnexpectedTypeException) {
throw new PropertyNotAccessibleException(
\is_array($objectOrArray) ? 'array' : $objectOrArray::class,
(string) $propertyPath,
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably add previous throwable to PropertyNotAccessibleException so we don't lose error context from property accessor

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 7af442d

$this->expectException(PropertyNotAccessibleException::class);
$this->expectExceptionMessage(
\sprintf(
'Unable to create a getter for property "%s::%s".',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about this message, it fits the context it was used for previously, but i don't think is good for errors with property accessor.
maybe we should change the message? @HypeMC

@HypeMC HypeMC changed the base branch from 1.x to 2.x December 15, 2025 19:19
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.

2 participants