Add MSG91 metadata tracking#135
Conversation
Greptile Summary
Confidence Score: 3/5The change needs attention before merge because generic GEOSMS routing can now apply provider-specific metadata validation before delegating to child adapters. The touched area is small and covered by focused tests, but the split-send metadata path introduces cross-provider behavior that can reject otherwise valid sends. src/Utopia/Messaging/Adapter/SMS/GEOSMS.php
What T-Rex did
Reviews (5): Last reviewed commit: "Validate GEOSMS tracking metadata before..." | Re-trigger Greptile |
lohanidamodar
left a comment
There was a problem hiding this comment.
Looks good, tests failing make sure not related.
| if (\count($batches) > 1 && $metadata !== null) { | ||
| foreach ([MetadataParameter::CRQID, MetadataParameter::UUID] as $parameter) { | ||
| $key = $parameter->value; | ||
|
|
||
| if (!\array_key_exists($key, $metadata)) { | ||
| continue; | ||
| } | ||
|
|
||
| if (!\is_string($metadata[$key])) { | ||
| throw new \InvalidArgumentException("Msg91 {$key} metadata must be a string."); | ||
| } | ||
|
|
||
| if (\strlen($metadata[$key]) > 80 || !\preg_match('/^[A-Za-z0-9_.-]+$/', $metadata[$key])) { | ||
| throw new \InvalidArgumentException("Msg91 {$key} metadata must be 80 characters or less and contain only alphanumeric characters, underscores, dots, or hyphens."); |
There was a problem hiding this comment.
GEOSMS is a generic router, but this branch applies MSG91-only CRQID and UUID rules whenever a send is split into multiple batches. A GEOSMS setup that routes only to non-MSG91 adapters can now reject metadata such as CRQID => "order 123" before any child adapter runs, even though those adapters would otherwise ignore or preserve the metadata. Because this runs before the per-adapter try block, the same invalid value also aborts the entire send() instead of being reported under the affected adapter while later batches continue. Please leave provider-specific validation to the MSG91 adapter, or only apply it inside the child-send path for batches that are actually sent through MSG91.
What does this PR do?
Adds support for MSG91 request tracking metadata on SMS messages.
This introduces a provider-specific
MetadataParameterenum for MSG91-supported metadata keys, stores optional metadata on SMS messages, and attaches supported metadata fields to MSG91 flow requests.CRQIDandUUIDare validated against MSG91 documented constraints before sending and are kept as request-level MSG91 fields.GEOSMS now preserves SMS metadata when routing messages to a single downstream send. When GEOSMS fans out one message into multiple adapter sends, it derives unique request-level
CRQIDandUUIDvalues per child request to avoid duplicated provider tracking identifiers while preserving correlation.Test Plan
./vendor/bin/phpunit tests/Messaging/Adapter/SMS/Msg91Test.php tests/Messaging/Adapter/SMS/GEOSMSTest.php./vendor/bin/pint --preset psr12 --test src/Utopia/Messaging/Adapter/SMS/Msg91.php src/Utopia/Messaging/Adapter/SMS/GEOSMS.php src/Utopia/Messaging/Adapter/SMS/Msg91/MetadataParameter.php src/Utopia/Messaging/Messages/SMS.php tests/Messaging/Adapter/SMS/Msg91Test.php tests/Messaging/Adapter/SMS/GEOSMSTest.php./vendor/bin/phpstan analyse --memory-limit=2G --level=6 src/Utopia/Messaging/Messages/SMS.php src/Utopia/Messaging/Adapter/SMS/Msg91.php src/Utopia/Messaging/Adapter/SMS/GEOSMS.php src/Utopia/Messaging/Adapter/SMS/Msg91/MetadataParameter.php tests/Messaging/Adapter/SMS/Msg91Test.php tests/Messaging/Adapter/SMS/GEOSMSTest.phpRelated PRs and Issues
#XXXX
Have you read the Contributing Guidelines on issues?
Yes.