Skip to content

feat(breaking): add Vonage Messages API adapter - #143

Closed
deepshekhardas wants to merge 9 commits into
utopia-php:mainfrom
deepshekhardas:fix/pr-111-vonage-messages
Closed

feat(breaking): add Vonage Messages API adapter#143
deepshekhardas wants to merge 9 commits into
utopia-php:mainfrom
deepshekhardas:fix/pr-111-vonage-messages

Conversation

@deepshekhardas

Copy link
Copy Markdown

Rebased on latest main with conflict resolution.

Conflicts resolved:

  • Skipped final rename commit (Vonage→VonageLegacy) — already done upstream
  • All adapter/test files applied cleanly

@github-actions

Copy link
Copy Markdown

Thanks for contributing! This repository is a read-only mirror; development for this library happens in packages/messaging in the utopia-php monorepo. Please open this pull request there instead.

@github-actions github-actions Bot closed this Jul 25, 2026
@greptile-apps

greptile-apps Bot commented Jul 25, 2026

Copy link
Copy Markdown

Greptile Summary

Adds an SMS adapter for Vonage's Messages API.

  • Sends JSON requests to the Vonage Messages endpoint using configured API credentials.
  • Supports adapter-level and message-level sender values.
  • Adds credential-gated integration coverage for both sender configurations.

Confidence Score: 3/5

The empty-recipient crash should be fixed before this adapter is merged, and deterministic coverage should be added for its request and error paths.

The shared send validation permits an empty recipient array, while the new adapter unconditionally reads its first element and passes null to a string-only function; the credential-gated tests do not exercise this or the adapter's failure handling in normal CI.

Files Needing Attention: src/Utopia/Messaging/Adapter/SMS/VonageMessages.php, tests/Messaging/Adapter/SMS/VonageMessagesTest.php

Important Files Changed

Filename Overview
src/Utopia/Messaging/Adapter/SMS/VonageMessages.php Implements the Vonage Messages API request and response handling, but crashes when passed an SMS with no recipients.
tests/Messaging/Adapter/SMS/VonageMessagesTest.php Adds credential-gated live success tests, without deterministic coverage of request construction or failure handling.

Fix All in Claude Code Fix All in Codex

Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
src/Utopia/Messaging/Adapter/SMS/VonageMessages.php:61
**Empty recipients crash processing**

When an SMS has an empty `to` array, the inherited validation permits it, but this line accesses index 0 and passes null to `ltrim()`, causing the send operation to fail with a `TypeError` instead of returning a messaging response.

### Issue 2 of 2
tests/Messaging/Adapter/SMS/VonageMessagesTest.php:18-20
**Adapter behavior lacks deterministic coverage**

These tests skip without live credentials and exercise only successful deliveries, leaving the new request construction and HTTP, transport, and malformed-response handling untested in normal CI. Add deterministic client or local-server tests that assert the outgoing request and representative error responses.

Reviews (1): Last reviewed commit: "fix: address review feedback and harden ..." | Re-trigger Greptile


protected function process(SMSMessage $message): array
{
$to = \ltrim($message->getTo()[0], '+');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Empty recipients crash processing

When an SMS has an empty to array, the inherited validation permits it, but this line accesses index 0 and passes null to ltrim(), causing the send operation to fail with a TypeError instead of returning a messaging response.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Utopia/Messaging/Adapter/SMS/VonageMessages.php
Line: 61

Comment:
**Empty recipients crash processing**

When an SMS has an empty `to` array, the inherited validation permits it, but this line accesses index 0 and passes null to `ltrim()`, causing the send operation to fail with a `TypeError` instead of returning a messaging response.

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code Fix in Codex

Comment on lines +18 to +20
if (!$apiKey || !$apiSecret || !$to) {
$this->markTestSkipped('Vonage Messages credentials or recipient are not available.');
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Adapter behavior lacks deterministic coverage

These tests skip without live credentials and exercise only successful deliveries, leaving the new request construction and HTTP, transport, and malformed-response handling untested in normal CI. Add deterministic client or local-server tests that assert the outgoing request and representative error responses.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/Messaging/Adapter/SMS/VonageMessagesTest.php
Line: 18-20

Comment:
**Adapter behavior lacks deterministic coverage**

These tests skip without live credentials and exercise only successful deliveries, leaving the new request construction and HTTP, transport, and malformed-response handling untested in normal CI. Add deterministic client or local-server tests that assert the outgoing request and representative error responses.

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants