dataProvider delete method only throw Internal Server Error message for errors
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 30/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- react, typescript
Research direction
Start with the dataProvider delete path and the fetchHydra.js and HttpError.js locations shown in the console stack. Compare delete error handling with the PUT, POST, and GET paths, then verify that an HTTP error response containing hydra:description produces that message instead of the generic internal server error.
Written by the indexing model from the issue text.
Description
API Platform Admin version(s) affected: 3.4.5
Description
Using the useDelete hook, APIP-Admin only throw an 'Internal Server Error' error, even if the API return an error message.
For example, on the API side I have this:
throw new EntityDeleteForeignKeyException(
$this->translator->trans(
'error.entity.my_entity.delete.has_foreign_key',
[
'%my_entity%' => $item->value,
'%entity_linked%' => $this->translator->trans('entity.my_other_entity'),
]
)
);
This code return a 409 http status code, with the following body:
"@context": "/contexts/Error"
"@type": "hydra:Error"
"hydra:description": "My Error Message"
"hydra:title": "An error occurred"
Wich is at this point the intended behavior so there is no problem.
But then, on the admin side, when we delete the entity and we get a 409 response (in fact, no matter the status code, the result is the same for every HTTP errors), the APIP-admin dataProvider thrown an internal server error and does not take the hydra:description like it do with other methods (PUT, POST, GET...).
This is what is shown in the console when this occurs:
Error
at new HttpError (HttpError.js:33:23)
at eval (fetchHydra.js:53:39)
Aditionnal Context:
- If I remember well, the same type of error happens a while back, when the delete method return a 204 status (maybe it is linked to this https://github.com/api-platform/admin/issues/440)
- This may be a duplicate of this issue: https://github.com/api-platform/admin/issues/381, but as there where no activity since 2021, I didn't knew if it was ok to just add a comment or if I needed to create a new one
- Dominant language
- TypeScript
- Stars
- 516
- Forks
- 134
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from api-platform/admin
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
api-platform/admin#616 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 64/100
api-platform/admin#660 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 50/100
api-platform/admin#659 · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
api-platform/admin#631 · 6 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
api-platform/admin#626 · 1 comment · 1 reaction ·
All issues in api-platform/admin
Similar issues
-
clawsweeper:linked-pr-open clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:message-loss issue-rating: 🦞 diamond lobster maturity:stable P2
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#616 ·
-
ZCode 3.14.3 に対応する Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
supermomonga/zcode-acp#24 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
growthbook/growthbook#7100 ·
-
triage
Difficulty 1/5 1-3 hours Newbie friendliness 88/100