Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error description formatting for NotFoundHttpException in EntityValueResolver #48

Conversation

rela589n
Copy link
Contributor

@rela589n rela589n commented Nov 8, 2023

The value resolver provided by symfony (Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver) throws NotFoundHttpException when entity is not found:

if (null === $object && !$argument->isNullable()) {
    throw new NotFoundHttpException(sprintf('"%s" object not found by "%s".', $options->class, self::class).$message);
}

As the result, ApiExceptionFormatterListener formats response with following description:

{
    "error": "resource_not_found",
    "errorDescription": "\"App\\Entity\\MyEntity\" object not found by \"Symfony\\Bridge\\Doctrine\\ArgumentResolver\\EntityValueResolver\"."
}

It doesn't seem to be secure this way, and it would make sense to use generic resource_not_found_exception_message instead.

@rela589n rela589n requested a review from fre5h as a code owner November 8, 2023 10:52
@fre5h
Copy link
Member

fre5h commented Nov 8, 2023

@rela589n There is an error with uploading code coverage. I will fix it, then merge this request.

@fre5h fre5h merged commit 1e89fdd into stfalcon-studio:main Nov 8, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants