flarum/framework · error · BadRequestException
Invalid endpoint specified
Error message
Invalid endpoint specified
What it means
Generic guard in JsonApi::findEndpoint: no endpoint registered on the resolved collection matches the requested endpoint name ($this->endpointName), so endpoint routing cannot proceed. It fires when a client targets an API endpoint that the resource collection does not define. (The RuntimeException about extending AbstractResource is a sibling guard for collections of the wrong class.)
Solutions
- Check that the endpoint name in the request URL matches an endpoint defined in the resource class's endpoints() method
- Register the missing endpoint on the collection's AbstractResource subclass
- Verify the collection was resolved for the correct resource type and that resolveEndpoints() returns the expected endpoints
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at framework/core/src/Api/JsonApi.php:75 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of flarum/framework@4b939f6853 (2026-09-15).
Data as JSON: /api/errors/4f820df946050dc7.
Report an issue: GitHub.
Appendix: source
Thrown at framework/core/src/Api/JsonApi.php:75
return (new Context($this, $request))
->withCollection($collection)
->withEndpoint($this->findEndpoint($collection));
}
protected function findEndpoint(?Collection $collection): Endpoint
{
if (! $collection instanceof AbstractResource) {
throw new RuntimeException('Resource '.$collection::class.' must extend '.AbstractResource::class);
}
/** @var Endpoint $endpoint */
foreach ($collection->resolveEndpoints() as $endpoint) {
if ($endpoint->name === $this->endpointName) {
return $endpoint;
}
}
throw new BadRequestException('Invalid endpoint specified');
}
/**
* Get a collection by name or class.
*
* @throws ResourceNotFoundException if the collection has not been defined.
*/
public function getCollection(string $type): Collection
{
if (isset($this->collections[$type])) {
return $this->collections[$type];
}
foreach ($this->collections as $instance) {
if ($instance instanceof $type) {
return $instance;
}
}View on GitHub (pinned to 4b939f6853)