Reply
Member
Posts: 178
Registered: ‎03-19-2018
Kudos: 29
Solutions: 6

500 Errors coming from API request

[ Edited ]

The problem I'm seeing doesn't appear to be related to the latest release so I'm making a new topic on it to not clutter the hotfix thread that I posted in found here.

 

I found part of the problem, the post request that failed was because of an attribute ID missing. But the reason this was hard to nail down was because I was getting a 500 server error instead of some kind of 400 bad request error.

 

As for the second part of the errors I pointed out for webhooks, I still haven't discovered the problem. It's a very straightforward get request with the uuid at the end of the URL.

 

Current error stacktrace:

 

GuzzleHttp\Exception\ServerException: Server error: `GET http://localhost:8080/api/v1.0/webhook-events/29756f3f-fd97-47a1-9f0d-d2ca776cafc9` resulted in a `500 Internal Server Error` response:
   {"code":500,"message":"Error occurred."}
   
   
   .../vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
   .../vendor/guzzlehttp/guzzle/src/Middleware.php:66
   .../vendor/guzzlehttp/promises/src/Promise.php:203
   .../vendor/guzzlehttp/promises/src/Promise.php:156
   .../vendor/guzzlehttp/promises/src/TaskQueue.php:47
   .../vendor/guzzlehttp/promises/src/Promise.php:246
   .../vendor/guzzlehttp/promises/src/Promise.php:223
   .../vendor/guzzlehttp/promises/src/Promise.php:267
   .../vendor/guzzlehttp/promises/src/Promise.php:225
   .../vendor/guzzlehttp/promises/src/Promise.php:62
   .../vendor/guzzlehttp/guzzle/src/Client.php:131
   .../vendor/ubnt/ucrm-plugin-sdk/src/UcrmPluginSdk/Service/UcrmApi.php:210
   .../vendor/ubnt/ucrm-plugin-sdk/src/UcrmPluginSdk/Service/UcrmApi.php:119

And the docker prod.log:

[2019-01-10 08:17:40] request.INFO: Matched route "api_webhook_event_get". {"route":"api_webhook_event_get","route_parameters":{"_controller":"ApiBundle\\Controller\\WebhookEventController:getAction","_format":null,"version":"1.0","uuid":"29756f3f-fd97-47a1-9f0d-d2ca776cafc9","_route":"api_webhook_event_get"},"request_uri":"http://localhost:8080/api/v1.0/webhook-events/29756f3f-fd97-47a1-9f0d-d2ca776cafc9","method":"GET"} []
[2019-01-10 08:17:40] security.DEBUG: Checking for guard authentication credentials. {"firewall_key":"api","authenticators":1} []
[2019-01-10 08:17:40] security.DEBUG: Calling getCredentials() on guard authenticator. {"firewall_key":"api","authenticator":"ApiBundle\\Security\\ApiAuthenticator"} []
[2019-01-10 08:17:40] security.DEBUG: Passing guard token information to the GuardAuthenticationProvider {"firewall_key":"api","authenticator":"ApiBundle\\Security\\ApiAuthenticator"} []
[2019-01-10 08:17:40] security.INFO: Guard authentication successful! {"token":"[object] (Symfony\\Component\\Security\\Guard\\Token\\PostAuthenticationGuardToken: PostAuthenticationGuardToken(user=\"test (App key)\", authenticated=true, roles=\"ROLE_ADMIN\"))","authenticator":"ApiBundle\\Security\\ApiAuthenticator"} []
[2019-01-10 08:17:40] security.DEBUG: Guard authenticator set no success response: request continues. {"authenticator":"ApiBundle\\Security\\ApiAuthenticator"} []
[2019-01-10 08:17:40] security.DEBUG: Remember me skipped: it is not configured for the firewall. {"authenticator":"ApiBundle\\Security\\ApiAuthenticator"} []
[2019-01-10 08:17:40] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\ContextErrorException: "Notice: Array to string conversion" at /usr/src/ucrm/vendor/jms/serializer/src/JMS/Serializer/JsonSerializationVisitor.php line 45 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\ContextErrorException(code: 0): Notice: Array to string conversion at /usr/src/ucrm/vendor/jms/serializer/src/JMS/Serializer/JsonSerializationVisitor.php:45)"} []

 

 

HTML, SCSS, Javascript(Ember.js), Ruby(Ruby on Rails), PHP
Ubiquiti Employee
Posts: 1,266
Registered: ‎03-21-2016
Kudos: 201
Solutions: 146

Re: 500 Errors coming from API request

@Brandon-W Thank you for the report. The webhook event bug is already fixed and will be in next release. We'll look into the 500 with missing attribute ID, there should absolutely be a 4xx validation error response instead of crash.

Highlighted
Member
Posts: 178
Registered: ‎03-19-2018
Kudos: 29
Solutions: 6

Re: 500 Errors coming from API request

Excellent! Thank you @UBNT-Ondra

HTML, SCSS, Javascript(Ember.js), Ruby(Ruby on Rails), PHP
Reply