core icon indicating copy to clipboard operation
core copied to clipboard

The root cause of the deserialization error remain hidden on API output

Open cay89 opened this issue 1 year ago • 1 comments

API Platform version(s) affected: 4.0.4

Description
If \ApiPlatform\State\Provider\DeserializeProvider::provide() throws an error, I only get the message "An error occurred" alongside the "trace", but it doesn't specify what the actual issue is.

If I catch it here and print it out, it turns out that the message is "Update is not allowed for this operation."

\ApiPlatform\State\Provider\DeserializeProvider image

How to reproduce
Throw an exception in \ApiPlatform\State\Provider\DeserializeProvider::provide().

Possible Solution
Add #[Groups(['jsonld', 'jsonproblem', 'jsonapi'])] attribute to ApiResource/Error::getDescription() method.

ApiResource/Error

#[SerializedName('description')]
#[Groups(['jsonld', 'jsonproblem', 'jsonapi'])]
public function getDescription(): string
{
    return $this->detail;
}

Result:

image

cay89 avatar Oct 14 '24 13:10 cay89

description is only for JSON-LD, detail should always be available though.

soyuka avatar Oct 16 '24 06:10 soyuka

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 15 '24 14:12 stale[bot]