- Issue created by @larowlan
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Can you define "broken"? π
- πΊπΈUnited States traviscarden
I assume this should go back to @tedbow now.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
So the endpoint actually just receives a plain, arbitrary JSON object, then? If so, this looks fine to me.
Really?! π³π€
I don't think that's the case.
I think @larowlan was only trying to demonstrate that
/openapi.yml
was not updated in π Change ApiContentUpdateForDemoController to save from auto-save instead of request data Active , yet still it allowed a seemingly invalid request to be considered acceptable.@larowlan, is this a duplicate of/a subset of π See why OpenAPI mistake for API error didn't cause test failures Active ?
- First commit to issue fork.
- πΊπΈUnited States tedbow Ithaca, NY, USA
I closed π See why OpenAPI mistake for API error didn't cause test failures Active and pushed the MR there to here
- πΊπΈUnited States tedbow Ithaca, NY, USA
copying my comment from π See why OpenAPI mistake for API error didn't cause test failures Active
@TravisCarden Why not instead of having isProd at all we just leave the other checks in \Drupal\experience_builder\EventSubscriber\ApiMessageValidatorBase::shouldValidate but remove the isProd() check. Then in we could
- catch the OpenApi validation errors and save the error info in Drupal state under xb_openapi_errors
- log the errors in \Drupal\experience_builder\EventSubscriber\ApiMessageValidatorBase::logFailure
- In \Drupal\Tests\BrowserTestBase::tearDown in our base test class(es?) and check the state there and throw an exception. We could have 1 trait for this across all test types
On advantage of this is that you won't fail on the first Open Validation error but could report on all the validation errors in the test run. Another advantage is it won't stop the test so you would also see another failure that would fail the test even if Open Validation failed.
This would also allow say if you were adding a new route locally but were sure on the return structure yet to not do the changes to openapi.yml or not complete the changes until you were sure on the structure, even if you had league/openapi-psr7-validator installed. It wouldn't stop you from working on the test for the new route. Openapi failures would still cause the test to fail but only at the very end so you would know if the rest of the test would pass.
I guess the con would be errors would not stop requests even if you had league/openapi-psr7-validator installed locally during manual testing, only automated tests. But we would also display the errors on the page.
We do something like this in \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase::tearDown but in that case we check the logs for specific errors.
- Merge request !486Issue #3494388 Debug why request validation was not triggered β (Open) created by tedbow
- πΊπΈUnited States tedbow Ithaca, NY, USA
So this MR https://git.drupalcode.org/project/experience_builder/-/merge_requests/485 proves at least validation is being triggered for responses.
Opened up https://git.drupalcode.org/project/experience_builder/-/merge_requests/486 to see if the problem is just that requests are not being validated.
π Change ApiContentUpdateForDemoController to save from auto-save instead of request data Active should have triggered a request validation error. I can confirm locally it does
- πΊπΈUnited States tedbow Ithaca, NY, USA
looking at the openapi related fails in 3494388-force-fail and the fact that 3494388-debug-request-validation doesn't have any openapi fails I think the problem is just requests
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
larowlan β changed the visibility of the branch 3494388-see-why-openapi to hidden.
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
@wim leers
ApiContentUpdateForDemoControllerTest
is broken in HEAD but it doesn't fail in CI.π Change ApiContentUpdateForDemoController to save from auto-save instead of request data Active changed the endpoint to no longer require a body (it uses the autosave store instead) but the openapi.yml wasn't updated.
Without the change in https://git.drupalcode.org/project/experience_builder/-/merge_requests/479 this causes a fail when run locally
1) Drupal\Tests\experience_builder\Functional\ApiContentUpdateForDemoControllerTest::testSave Failed asserting that two arrays are identical. --- Expected +++ Actual @@ @@ Array &0 [ - 'message' => 'Saved successfully.', + 'message' => 'Missing required header "Content-Type" for Request [patch /xb/api/content-update/{entityTypeId}/{entityId}]',
Updated the issue summary, which I should have done yesterday, but I quickly put this up before I finished for the day
- First commit to issue fork.
-
effulgentsia β
committed ccf7b669 on 0.x authored by
larowlan β
Issue #3494388: Openapi Request validation broken in HEAD
-
effulgentsia β
committed ccf7b669 on 0.x authored by
larowlan β
- πΊπΈUnited States effulgentsia
I merged MR 479. Not sure if we want to keep this issue open for further troubleshooting or do that in new issues.
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
I've opened https://git.drupalcode.org/project/experience_builder/-/merge_requests/487 as another attempt