weave icon indicating copy to clipboard operation
weave copied to clipboard

fix: validate object name

Open jamie-rasmussen opened this issue 9 months ago • 3 comments

Using Pydantic for validation should give us enforcement in both SDK and server.

Please let me know if you have thoughts on what the max length / valid characters should be if different than what I have here.

With this change, trying to do something like: weave.publish(['felix', 'jimbo', 'billie'], 'foo/bar')

Would yield:

ValidationError: 1 validation error for ObjSchemaForInsert
object_id
  String should match pattern '^[A-Za-z0-9._-]+$' [type=string_pattern_mismatch, input_value='foo/bar', input_type=str]
    For further information visit https://errors.pydantic.dev/2.6/v/string_pattern_mismatch

jamie-rasmussen avatar May 02 '24 18:05 jamie-rasmussen

would this crash the user's script though? I think as a general design principle, crashing user code feels like a thing we should always avoid.

jlzhao27 avatar May 02 '24 18:05 jlzhao27