weave
weave copied to clipboard
fix: validate object name
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
Preview this PR with FeatureBee: https://beta.wandb.ai/?betaVersion=25b8c32b83128a8c3bf753703d28c2a046be1c24
Preview this PR with FeatureBee: https://beta.wandb.ai/?betaVersion=f734533f07f5682b61dcae45bb6c28c11c21abd0
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.