Fix Bug In How getEnrolledFactors Handles the otp_devices API Data #28
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 fixes a critical bug in the OneLogin PHP SDK where
getEnrolledFactorsandgetFactorsmethods fail due to an API inconsistency in how the otp_devices endpoint returns data.Problem
The otp_devices API endpoint returns data wrapped in an object format
{otp_devices: [...]}instead of a flat array like other endpoints. This causes two critical failures:count(): Argument #1 ($value) must be of type Countable|array, stdClass giveninhandleDataResponsemethodempty($data[0])always evaluates to true for objects, causing the method to return empty arrays even when data existsOTPDeviceandAuthFactorconstructors throw exceptions when optional API fields are missingSolution
1. Fixed
handleDataResponsemethod inOneLoginClient.php2. Fixed model constructors with proper type handling
Impact
getEnrolledFactorsnow correctly processes otp_devices API responsesgetFactorsbenefits from the same robustness improvementsTesting
Comprehensive testing validates:
falseinstead of empty stringsnullfor better error detectionFixes #12.
Warning
https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba/usr/bin/php8.3 -n -c /tmp/nOwkcr /usr/bin/composer install(http block)https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/9614ac4d8061dc257ecc64cba1b140873dce8ad3/usr/bin/php8.3 -n -c /tmp/nOwkcr /usr/bin/composer install(http block)💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.