Fixed [API]- GET /api/conversations/{id} will result in a server error

stromb0li

Well-known member
Affected version
2.3.4
API Configuration:
Type: OAuth2 client
Client type: Confidential
Scope: conversation:read

GET https://mydomain.com/api/conversations/123456

This will result in a server error:
JSON:
{
  "errors": [
    {
      "code": "server_error_occurred",
      "message": "A server error occurred during the API request. Please try again later.",
      "params": []
    }
  ]
}

----
  • Error: Call to undefined method XF\Finder\ConversationMasterFinder::forUser()
  • src/XF/Api/ControllerPlugin/ConversationPlugin.php:26

Stack trace​

#0 src/XF/Api/Controller/ConversationController.php(328): XF\Api\ControllerPlugin\ConversationPlugin->assertViewableUserConversation('297', 'api')
#1 src/XF/Api/Controller/ConversationController.php(41): XF\Api\Controller\ConversationController->assertViewableUserConversation('297')
#2 src/XF/Mvc/Dispatcher.php(362): XF\Api\Controller\ConversationController->actionGet(Object(XF\Mvc\ParameterBag))
#3 src/XF/Api/Mvc/Dispatcher.php(30): XF\Mvc\Dispatcher->dispatchClass('XF:Conversation', 'Get', Object(XF\Api\Mvc\RouteMatch), Object(XF\Api\Controller\ConversationController), NULL)
#4 src/XF/Mvc/Dispatcher.php(121): XF\Api\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Api\Mvc\RouteMatch), Object(XF\Api\Controller\ConversationController), NULL)
#5 src/XF/Mvc/Dispatcher.php(63): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Api\Mvc\RouteMatch))
#6 src/XF/App.php(2826): XF\Mvc\Dispatcher->run()
#7 src/XF.php(806): XF\App->run()
#8 index.php(19): XF::runApp('XF\\Api\\App')
#9 {main}

Request state​

array(4) {
["url"] => string(22) "/api/conversations/297"
["referrer"] => bool(false)
["_GET"] => array(1) {
["/api/conversations/297"] => string(0) ""
}
["_POST"] => array(0) {
}
}
 
Looks like this is the fix:

/src/XF/Api/ControllerPlugin/ConversationPlugin.php

Find:
$finder = $this->finder(ConversationMasterFinder::class);

Replace with:
$finder = $this->finder(ConversationUserFinder::class);

Interestingly, the comment above it reflected ConversationUserFinder, so not sure why this one didn't get replaced. As far as I can tell, /src/XF/Finder/ConversationMasterFinder.php is no longer used / can be deleted; it's an empty class.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.5).

Change log:
Fix server error getting conversations by ID via API.
There may be a delay before changes are rolled out to the XenForo Community.
 
Interestingly, the comment above it reflected ConversationUserFinder, so not sure why this one didn't get replaced.
This was probably a human error when we modified this code.

As far as I can tell, /src/XF/Finder/ConversationMasterFinder.php is no longer used / can be deleted; it's an empty class.
The empty classes are deliberate for development purposes. They are for automatic type hinting.
 
Back
Top Bottom