Skip to content

Conversation

@arnav-makkar
Copy link
Contributor

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:

  • 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()

Link(s) to related issue(s)

…#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.
@github-actions github-actions bot added Language: PHP PR or issue that update PHP code Module: redcap PR or issue related to redcap module labels Jan 10, 2026
@MaximeBICMTL MaximeBICMTL self-requested a review January 15, 2026 05:16
Copy link
Contributor

@MaximeBICMTL MaximeBICMTL left a comment

Choose a reason for hiding this comment

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

Tested and it works on my machine.

image

Comment on lines +111 to +112
// Handle empty data gracefully (e.g., REDCap DET "Test" button sends
// empty data).
Copy link
Contributor

@MaximeBICMTL MaximeBICMTL Jan 17, 2026

Choose a reason for hiding this comment

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

Suggested change
// 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.

@arnav-makkar
Copy link
Contributor Author

Thank you. Please merge when free

@MaximeBICMTL
Copy link
Contributor

@arnav-makkar @driusan will handle merging whenever he gets the time. Also, letting the suggestion open for now.

@driusan driusan merged commit 99e96d6 into aces:main Jan 20, 2026
21 checks passed
GeorgeMurad pushed a commit to GeorgeMurad/Loris that referenced this pull request Jan 21, 2026
…#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language: PHP PR or issue that update PHP code Module: redcap PR or issue related to redcap module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type error on REDCap test DET button

4 participants