aws-samples / pcluster-manager

Manage AWS ParallelCluster through an easy to use web interface
https://pcluster.cloud
Apache License 2.0
65 stars 27 forks source link

Added API signature validation #472

Closed BarcoMasile closed 1 year ago

BarcoMasile commented 1 year ago

Description

Added API input validation mechanism + decorator to validate API invocation at the controller level.

Changes

How Has This Been Tested?

References

PR Quality Checklist

In order to increase the likelihood of your contribution being accepted, please make sure you have read both the Contributing Guidelines and the Project Guidelines

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

mendaomn commented 1 year ago

General questions: how is the text of the error messages generated? It's not a concern for this PR, but I'm wondering:

BarcoMasile commented 1 year ago

General questions: how is the text of the error messages generated? It's not a concern for this PR, but I'm wondering:

  • can they be centralized, or otherwise searched through in case we ever needed to spot a specific issue starting from the error message? (e.g. we find the error message, and we need to get to the schema definition to see if there is a bug)
  • can they be internationalised, or customized at all?

The library of choice allows for customization of error message at the field level so we can (in the future) for example return i18n keys to the frontend and let the frontend translate those for the users @mendaomn

mendaomn commented 1 year ago

General questions: how is the text of the error messages generated? It's not a concern for this PR, but I'm wondering:

  • can they be centralized, or otherwise searched through in case we ever needed to spot a specific issue starting from the error message? (e.g. we find the error message, and we need to get to the schema definition to see if there is a bug)
  • can they be internationalised, or customized at all?

The library of choice allows for customization of error message at the field level so we can (in the future) for example return i18n keys to the frontend and let the frontend translate those for the users @mendaomn

Good, I noticed you added the request.path in the ValidationError constructor. Thus, we should be able to easily traceback to the failing schema in case of validation errors. Good job!