Skip to content

IRI Converter Exception Messages #2172

@ragboyjr

Description

@ragboyjr

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:

  1. No item route associated with the type "%s"
  2. No collection route associated with type "%s"
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions