modal-labs / modal-client

Python client library for Modal
https://modal.com/docs
Apache License 2.0
271 stars 35 forks source link

Prevent colons and slashes in environment names #1956

Closed kramstrom closed 3 months ago

kramstrom commented 3 months ago

MOD-2914

Adds client side validation on invalid environment names to ensure new environments can't be created with invalid names and existing ones can't be updated to have invalid names.

Still allows existing ones with invalid names to be updated to valid ones and operations such as list/delete will still work with invalid ones

kramstrom commented 3 months ago

I would suggest that we copy what we do with check_object_name and run the environment name check locally, providing a more detailed error message. (i.e., it's very annoying to get an error that says you've used illegal characters but doesn't tell you which ones they are).

Also, is this going to prevent people from renaming or deleting environments with newly-illegal names? Something to consider, as that would also be annoying...

I added a check similar to check_object_name called check_environment_name that validates the environment locally first and gives a friendlier message.

Also added some tests to make sure you cannot create/update environments with invalid names but you can update an environment with an invalid name to a new valid name. Also didn't add the checks for other environment actions, so you can still delete/list environments if they have invalid names