Uh oh!
There was an error while loading. Please reload this page.
feat: add Vonage Messages API adapter - #127
Conversation
Greptile SummaryThis PR renames the existing
Confidence Score: 2/5
Important Files Changed
Prompt To Fix All With AI### Issue 1
src/Utopia/Messaging/Adapter/SMS/VonageLegacy.php:20-25
**Missing `parent::__construct()` causes fatal error on every send**
The original `Vonage.php` called `parent::__construct()`, which this PR explicitly removes. The base `Adapter` class initializes two typed properties there — `$sendCounter` (non-nullable `Counter`) and `$clientFactory` (readonly `?Closure`) — both via constructor promotion or direct assignment. Without that call, both properties remain uninitialized. PHP throws `Fatal error: Typed property Utopia\Messaging\Adapter::$sendCounter must not be accessed before initialization` the first time `send()` calls `recordResponse()`, which is every successful delivery. Every other SMS adapter in the codebase (`Twilio`, `Clickatell`, `Sinch`, etc.) calls `parent::__construct()`.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (8): Last reviewed commit: "chore: remove old Vonage files after ren..." | Re-trigger Greptile |
| use Utopia\Messaging\Response; | ||
| class Vonage extends SMSAdapter | ||
| class VonageLegacy extends SMSAdapter |
There was a problem hiding this comment.
Breaking rename with no backward-compatibility alias
Renaming Vonage → VonageLegacy drops the original class name entirely. Any downstream code using new \Utopia\Messaging\Adapter\SMS\Vonage(...) or use Utopia\Messaging\Adapter\SMS\Vonage will throw a fatal Class not found error after upgrading this library. The PR description mentions a "backward compat note" but no alias or deprecation shim is present in the diff. Consider adding class_alias(VonageLegacy::class, 'Utopia\\Messaging\\Adapter\\SMS\\Vonage'); at the bottom of this file (or in a dedicated compat file), or coordinate a semver-major release.
| public function testSendSMS(): void | ||
| { | ||
| $this->markTestSkipped('Vonage Messages credentials are not available.'); | ||
| /* | ||
| $apiKey = \getenv('VONAGE_MESSAGES_API_KEY'); | ||
| $apiSecret = \getenv('VONAGE_MESSAGES_API_SECRET'); | ||
| $sender = new VonageMessages($apiKey, $apiSecret); | ||
| $message = new SMS( | ||
| to: [\getenv('VONAGE_MESSAGES_TO')], | ||
| content: 'Test Content', | ||
| from: \getenv('VONAGE_MESSAGES_FROM'), | ||
| ); | ||
| $response = $sender->send($message); | ||
| $this->assertNotEmpty($response['results']); | ||
| $this->assertNotEmpty($response['results'][0]['success']); | ||
| */ | ||
| } |
There was a problem hiding this comment.
The test immediately calls markTestSkipped and the real assertions are in a block comment rather than an if (! $creds) { markTestSkipped(); } guard pattern. Tests for other adapters (e.g., VonageLegacyTest) use live credentials gated by env vars. If VONAGE_MESSAGES_API_KEY etc. are simply not available in CI, the existing skip-unless-env-var pattern should be used here too, so the test actually executes when credentials are configured.
deepshekhardas
commented
Jul 11, 2026
Following up - this PR has been waiting for review. Happy to address any feedback or make changes. |
Renames the existing Vonage adapter to VonageLegacy and adds a new VonageMessages adapter using the modern Vonage Messages API (V1). Based on PR utopia-php#111 by bhardwajparth51.
| public function __construct( | ||
| private readonly string $apiKey, | ||
| private readonly string $apiSecret, | ||
| private readonly ?string $from = null, | ||
| private string $apiKey, | ||
| private string $apiSecret, | ||
| private ?string $from = null | ||
| ) { | ||
| parent::__construct(); | ||
| } |
There was a problem hiding this comment.
Missing
parent::__construct() causes fatal error on every send
The original Vonage.php called parent::__construct(), which this PR explicitly removes. The base Adapter class initializes two typed properties there — $sendCounter (non-nullable Counter) and $clientFactory (readonly ?Closure) — both via constructor promotion or direct assignment. Without that call, both properties remain uninitialized. PHP throws Fatal error: Typed property Utopia\Messaging\Adapter::$sendCounter must not be accessed before initialization the first time send() calls recordResponse(), which is every successful delivery. Every other SMS adapter in the codebase (Twilio, Clickatell, Sinch, etc.) calls parent::__construct().
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Utopia/Messaging/Adapter/SMS/VonageLegacy.php
Line: 20-25
Comment:
**Missing `parent::__construct()` causes fatal error on every send**
The original `Vonage.php` called `parent::__construct()`, which this PR explicitly removes. The base `Adapter` class initializes two typed properties there — `$sendCounter` (non-nullable `Counter`) and `$clientFactory` (readonly `?Closure`) — both via constructor promotion or direct assignment. Without that call, both properties remain uninitialized. PHP throws `Fatal error: Typed property Utopia\Messaging\Adapter::$sendCounter must not be accessed before initialization` the first time `send()` calls `recordResponse()`, which is every successful delivery. Every other SMS adapter in the codebase (`Twilio`, `Clickatell`, `Sinch`, etc.) calls `parent::__construct()`.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Port of PR #111 by bhardwajparth51.
Renames the existing Vonage adapter to VonageLegacy and adds a new VonageMessages adapter using the modern Vonage Messages API (V1) which is more cost-effective and versatile.
Changes: