Repository navigation
fix(messaging): treat explicit nulls as omitted in push message create - #13849
ChiragAgg5k wants to merge 1 commit into
Conversation
Optional params skip validation when null, so an explicit null bypassed the param default and reached the action, crashing on the non-nullable signature or on count(null) with a 500.
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
|
Superseded by #13852, which fixes this at the framework level (utopia-php/monorepo#327) instead of patching push message create alone. |
What does this PR do?
POST /v1/messaging/messages/pushreturns a 500 when a client sends an explicitnullfor any optional param. This is happening in production (about 130 events since 5 Sep, all withimage: null).utopia-php/http skips validation for an optional param whose value is
null, and it passes thatnullto the action instead of the param default.Push\Create::action()declared most optional params as non-nullable (string $image,int $badge,bool $draft, …), so PHP threw aTypeError.topics/users/targetswere already?array, but anullthere reached\count()and threw as well.The fix makes the optional scalars nullable and restores the declared defaults with
??=where the action depends on the value (arrays,badge, booleans,priority). The string params were already only checked with!empty(). An explicitnullnow behaves the same as leaving the param out, which matchesPush\Updateand the fix already onmaininExecutions\Create($path ??= '/').Before
After
All responses were captured against a local stack. Dev-mode
file/tracefields are left out.Test Plan
testCreatePushWithNullOptionalParamssends every optional param asnull. It checks for a 201 and reads the message back to confirm the stored recipients are empty arrays and the stored data holds onlytitle,bodyand the defaultpriority. It then sendsnullrecipients withoutdraftand expects a 400message_missing_target.Failed asserting that 500 is identical to 201) and pass with the fix.MessagingCustomServerTestandMessagingConsoleClientTest: 47 tests each, all passing (8 skipped).pint --testpasses on the changed files.Related PRs and Issues
None.
Checklist