Skip to content

Commit

Permalink
fix: Disallow None id encoding in AsyncNode.to_global_id() (#2898) (
Browse files Browse the repository at this point in the history
#2955)

Co-authored-by: Gyubong Lee <jopemachine@naver.com>
  • Loading branch information
lablup-octodog and jopemachine authored Oct 24, 2024
1 parent f6c8f55 commit 67e5531
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions changes/2898.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disallow `None` id encoding in `AsyncNode.to_global_id()`.
4 changes: 1 addition & 3 deletions src/ai/backend/manager/api/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1269,9 +1269,7 @@ type ContainerRegistryNode implements Node {
"""The ID of the object"""
id: ID!

"""
Added in 24.09.0. The undecoded UUID type id of DB container_registries row.
"""
"""Added in 24.09.0. The UUID type id of DB container_registries row."""
row_id: UUID
name: String

Expand Down
2 changes: 1 addition & 1 deletion src/ai/backend/manager/models/container_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class Meta:
description = "Added in 24.09.0."

row_id = graphene.UUID(
description="Added in 24.09.0. The undecoded UUID type id of DB container_registries row."
description="Added in 24.09.0. The UUID type id of DB container_registries row."
)
name = graphene.String()
url = graphene.String(required=True, description="Added in 24.09.0.")
Expand Down
6 changes: 4 additions & 2 deletions src/ai/backend/manager/models/gql_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ async def node_resolver(cls, only_type, root, info, id):
return await cls.get_node_from_global_id(info, id, only_type=only_type)

@staticmethod
def to_global_id(type_, id) -> str:
return base64(f"{type_}:{id}")
def to_global_id(type_, id_) -> str:
if id_ is None:
raise Exception("Encoding None value as Global ID is not allowed.")
return base64(f"{type_}:{id_}")

@classmethod
def resolve_global_id(cls, info, global_id: str) -> tuple[str, str]:
Expand Down

0 comments on commit 67e5531

Please sign in to comment.