The default IRI Converter uses the symfony router to handle the generation of the IRI values per entity. If there are any issues with IRI generation or lookup by IRI, the exceptions that get thrown are hard to understand/misleading because the errors will be associated with Routing and not with denormalizing an entity or fetching an entity by an IRI.
Here are a few examples of some scenarios that generate errors with the IRI Converter and have confusing error messages:
- No item route associated with the type "%s"
- No collection route associated with type "%s"
- No route matches "%s".
You can get errors 1 and 2 if API Platform tries to serialize an entity that does not have a GET item/collection operation defined which is common when working with DTO's. See this Stackoverflow Post
Error 3 can show up if you pass in malformed IRI value for a relationship entity.
POST books
{
"title": "Some Value"
"author": "badvalue" // should be an iri formatted like /authors/1
}
I think a possible solution for friendlier error messages would be to catch exceptions thrown in the in the normalizers and give error messages that are closer to the actual problem.
The default IRI Converter uses the symfony router to handle the generation of the IRI values per entity. If there are any issues with IRI generation or lookup by IRI, the exceptions that get thrown are hard to understand/misleading because the errors will be associated with Routing and not with denormalizing an entity or fetching an entity by an IRI.
Here are a few examples of some scenarios that generate errors with the IRI Converter and have confusing error messages:
You can get errors 1 and 2 if API Platform tries to serialize an entity that does not have a GET item/collection operation defined which is common when working with DTO's. See this Stackoverflow Post
Error 3 can show up if you pass in malformed IRI value for a relationship entity.
I think a possible solution for friendlier error messages would be to catch exceptions thrown in the in the normalizers and give error messages that are closer to the actual problem.