admin icon indicating copy to clipboard operation
admin copied to clipboard

violationKey in getSubmissionErrors is undefined / validation results in generic "Server communication error"

Open herndlm opened this issue 1 year ago • 1 comments

API Platform version(s) affected: 3.2.20

@api-platform/[email protected] @api-platform/[email protected]

Description

API validation errors result in generic "Server communication error" in react-admin

How to reproduce

Possible Solution

Additional Context

Interestingly it seems to be still working with @api-platform/[email protected]. What confuses me is that 3.4.6 claims to fix issues like these.

API response: content-type: application/problem+json; charset=utf-8 body:

{
  "@id": "\\/validation_errors\\/6b3befbc-2f01-4ddf-be21-b57898905284",
  "@type": "ConstraintViolationList",
  "status": 422,
  "violations": [
    {
      "propertyPath": "entitlements",
      "message": "At least one product must be selected if policy is \\u0022restricted\\u0022.",
      "code": "6b3befbc-2f01-4ddf-be21-b57898905284"
    }
  ],
  "detail": "entitlements: At least one product must be selected if policy is \\u0022restricted\\u0022.",
  "hydra:title": "An error occurred",
  "hydra:description": "entitlements: At least one product must be selected if policy is \\u0022restricted\\u0022.",
  "type": "\\/validation_errors\\/6b3befbc-2f01-4ddf-be21-b57898905284",
  "title": "An error occurred"
}

react-admin UI behaviour image

Step debugging with 3.4.5 where it works image

Step debugging with 3.4.6 where it doesn't work image

There seems to be something going on with the protocol/domain/port part in props or their values. I wonder if I misconfigured something, somewhere. Not sure, if related, but API platform's rfc_7807_compliant_errors is true and changing this doesn't change anything apparently.

Is this in any way useful, maybe to give me further tips at least how to debug? I can't create a simple producer at the moment unfortunately.

herndlm avatar Apr 19 '24 14:04 herndlm

Try to debug more where hydra response is expanded, I guess it works with api-platform/core 3.1.x but not with 3.2.x (?, not verified):

https://github.com/api-platform/admin/blob/5f80c05577413af5037baaf4a9619785780912a4/src/hydra/fetchHydra.ts#L58-L62

PawelSuwinski avatar Apr 25 '24 21:04 PawelSuwinski

3.4.5 works for me as expected with api platform 3.2, 3.3.2 tested.

@ type, @ id gets the extra prefix as @herndlm pictures shows

server response looks correct: image

getDocumentationUrlFromHeaders(headers) gives back full url to /api/docs.jsonld

@PawelSuwinski do you have any other suggestion?

another hint maybe less usefull it does not step into the documentLoader

my question is, which one is the correct format?

papppeter avatar May 08 '24 16:05 papppeter

I unfortunately didn't find more time to further debug it yet :/ but looks like you found the issue and fix already @PawelSuwinski. thx!

herndlm avatar May 10 '24 12:05 herndlm

@herndlm and @papppeter thanks for test cases and for debugging.

PawelSuwinski avatar May 13 '24 09:05 PawelSuwinski