Skip to content

fix: improve Msg91 error handling to extract API error messages#133

Open
deepshekhardas wants to merge 2 commits into
utopia-php:mainfrom
deepshekhardas:fix/msg91-error-handling
Open

fix: improve Msg91 error handling to extract API error messages#133
deepshekhardas wants to merge 2 commits into
utopia-php:mainfrom
deepshekhardas:fix/msg91-error-handling

Conversation

@deepshekhardas

Copy link
Copy Markdown

No description provided.

@greptile-apps

greptile-apps Bot commented Jun 17, 2026

Copy link
Copy Markdown

Greptile Summary

This PR improves the error handling in the Msg91 SMS adapter so that when the API returns a non-200 response, the failure result now carries the actual error message extracted from the response body instead of the static string "Unknown error".

  • Checks $result['response']['message'] then $result['response']['error'] in order, with is_string guards and a json_encode fallback for non-scalar values.
  • Transport-layer failures (network errors, DNS, TLS) still land in the same else branch but the top-level $result['error'] string — populated by request() on ClientExceptionInterface — is not consulted, so those cases still surface as "Unknown error".

Confidence Score: 5/5

The change is self-contained to the error-reporting path and does not affect the successful delivery logic; safe to merge.

The only new finding is a missed opportunity to surface transport-level error strings — a non-blocking quality gap that does not affect correctness of the success path or the overall delivery flow.

Files Needing Attention: No files require special attention beyond the single changed file.

Important Files Changed

Filename Overview
src/Utopia/Messaging/Adapter/SMS/Msg91.php Adds structured error-message extraction from API response body (checking message and error keys), with is_string/json_encode guards; does not yet check the top-level $result['error'] for transport-layer failures.

Reviews (5): Last reviewed commit: "fix: guard Msg91 error extraction agains..." | Re-trigger Greptile

Comment thread src/Utopia/Messaging/Adapter/SMS/Msg91.php
Comment thread src/Utopia/Messaging/Adapter/SMS/Msg91.php
@deepshekhardas

Copy link
Copy Markdown
Author

Following up - Msg91 error handling fix. Let me know if changes needed.

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.

1 participant