Validating bodies

Posted by / 20-Dec-2019 10:02

API Response error messages: There will be change in the error message returned to user.

For example, On current master if user passes more than 255 characters for volume name then below error message is returned to user from cinder-api: Invalid input received: name has The output from the request validation layer should not compromise data or expose private data to an external user.

If the request body parameters fails the validation specified by the resource schema, a validation error wrapped in HTTPBad Request will be returned from the server. These changes would make the API method code dirty and we needed to create multiple patches due to incomplete validation.

If using JSON Schema definitions instead, acceptable request formats are clear and we don’t need to do ad-hoc works in the future.

Currently Cinder doesn’t have a consistent request validation layer.

A jsonschema validator object can be used to check each resource against an appropriate schema for that resource.

If the validation passes, the request can follow the existing flow of control through the resource manager to the backend. Each API definition should be added with the following ways: Before the API validation framework, we needed to add the validation code into each API method in ad-hoc.

Pecan would make the implementations of API routes(URL, METHOD) easy.

API Response code changes: There are some occurrences where API response code will change while adding schema layer for them.

validating bodies-41validating bodies-49validating bodies-83

There is inherently no body and the error happens before the hook above runs.

One thought on “validating bodies”