-
Notifications
You must be signed in to change notification settings - Fork 192
[REDCap] Handle empty data gracefully in notifications endpoint (#9895) #10257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REDCap] Handle empty data gracefully in notifications endpoint (#9895) #10257
Conversation
…#9895) When REDCap sends empty data (e.g., via the DET 'Test' button), the notifications endpoint now returns a successful HTTP 200 response instead of throwing a TypeError. Previously, null data was passed directly to RedcapNotification::__construct() which expects an array type, causing: RedcapNotification::__construct(): Argument aces#1 ($props) must be of type array, null given This fix adds an early check after data parsing to detect null or empty array data and gracefully returns an empty response, preventing the type error while maintaining normal notification processing for valid data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Handle empty data gracefully (e.g., REDCap DET "Test" button sends | ||
| // empty data). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Handle empty data gracefully (e.g., REDCap DET "Test" button sends | |
| // empty data). | |
| // Return an empty response when receiving empty data, which is notably | |
| // sent by the test button of the REDCap data entry trigger. |
Nit (optional): I personally do not like to use subjective wording (like "gracefully") or acronyms in code comments. But that may be a matter of personal taste, the PR is good.
|
Thank you. Please merge when free |
|
@arnav-makkar @driusan will handle merging whenever he gets the time. Also, letting the suggestion open for now. |
…#9895) (aces#10257) This fixes a TypeError that occurred when REDCap sends empty data to the LORIS notifications endpoint, such as when using the "Test" button on the REDCap Data Entry Trigger (DET). **Changes:** - Added an early validation check in the _handlePOST() method to detect null or empty data - Returns a graceful HTTP 200 response when empty data is received - Prevents TypeError from being thrown when null is passed to `RedcapNotification::__construct()` * Resolves aces#9895

Brief summary of changes
This PR fixes a TypeError that occurred when REDCap sends empty data to the LORIS notifications endpoint, such as when using the "Test" button on the REDCap Data Entry Trigger (DET).
Changes:
RedcapNotification::__construct()Link(s) to related issue(s)