Skip to content

Commit

Permalink
fix: Relax Ref Constraints and Add Helper Text to Error (#2274)
Browse files Browse the repository at this point in the history
* init

* init

* init

* init

* fixed

* fixed

* fixed
  • Loading branch information
tssweeney authored Aug 29, 2024
1 parent 60d7d0d commit ff8b62d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions weave/trace/refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import urllib
from typing import Any, Union

from ..trace_server import refs_internal, validation
from ..trace_server import refs_internal

DICT_KEY_EDGE_NAME = refs_internal.DICT_KEY_EDGE_NAME
LIST_INDEX_EDGE_NAME = refs_internal.LIST_INDEX_EDGE_NAME
Expand Down Expand Up @@ -58,7 +58,8 @@ def __post_init__(self) -> None:
refs_internal.validate_no_slashes(self.digest, "digest")
refs_internal.validate_no_colons(self.digest, "digest")
refs_internal.validate_extra(list(self.extra))
validation.object_id_validator(self.name)
refs_internal.validate_no_slashes(self.name, "name")
refs_internal.validate_no_colons(self.name, "name")

def uri(self) -> str:
u = f"weave:///{self.entity}/{self.project}/object/{self.name}:{self.digest}"
Expand Down
5 changes: 2 additions & 3 deletions weave/trace_server/refs_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import urllib
from typing import Any, Union

from . import validation

WEAVE_INTERNAL_SCHEME = "weave-trace-internal"
WEAVE_SCHEME = "weave"
WEAVE_PRIVATE_SCHEME = "weave-private"
Expand Down Expand Up @@ -106,7 +104,8 @@ def __post_init__(self) -> None:
validate_no_slashes(self.version, "version")
validate_no_colons(self.version, "version")
validate_extra(self.extra)
validation.object_id_validator(self.name)
validate_no_slashes(self.name, "name")
validate_no_colons(self.name, "name")

def uri(self) -> str:
u = f"{WEAVE_INTERNAL_SCHEME}:///{self.project_id}/object/{self.name}:{self.version}"
Expand Down
3 changes: 2 additions & 1 deletion weave/trace_server/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ def _validate_object_name_charset(name: str) -> None:
# Object names must be alphanumeric with dashes
invalid_chars = re.findall(r"[^\w._-]", name)
if invalid_chars:
invalid_char_set = list(set(invalid_chars))
raise ValueError(
f"Invalid object name: {name}. Contains invalid characters: {invalid_chars}"
f"Invalid object name: {name}. Contains invalid characters: {invalid_char_set}. Please upgrade your `weave` package to `>0.51.0` to prevent this error."
)

if not name:
Expand Down
2 changes: 1 addition & 1 deletion weave/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "0.51.0"
VERSION = "0.51.1"

0 comments on commit ff8b62d

Please sign in to comment.