treeverse / lakeFS

lakeFS - Data version control for your data lake | Git for data
https://docs.lakefs.io
Apache License 2.0
4.35k stars 346 forks source link

Better API error messages for malformed tag names #7932

Open nicholasjng opened 2 months ago

nicholasjng commented 2 months ago

x-ref https://github.com/aai-institute/lakefs-spec/issues/282.

tl,dr: We have an internal user that got stuck with API errors creating a tag with spaces in the name, which is apparently not allowed. The error message, however,

lakefs.exceptions.BadRequestException: code: 400, reason: Bad Request, body: {'message': 'argument tagID: tag id: invalid value: validation error'}

is not helpful. I'm guessing it comes from the server, since otherwise we would see pydantic client-side errors. This could use a better hint at what went actually wrong.

What would be even cooler is if the OpenAPI-generated pydantic type got a custom validator that catches exactly this, since then we wouldn't even make it to the API request. Another (less nice) way to achieve this would be to place a quick validation handler into the tag creation method in the Python wrapper.

simonhammes commented 1 month ago

The actual validation logic is defined here, for anyone who's willing to work on this: https://github.com/treeverse/lakeFS/blob/857e22bc0b6c0aa3e54729a70037371dc1c04327/pkg/graveler/validate.go#L49-L80