feat: add ID format validation to identity schemas (#9153)
* feat: add ID format validation to identity schemas Add ID format validation to IdentityCreate, IdentityUpsert, and IdentityUpdate schemas using existing validator types from letta.validators. Changes: - agent_ids: Optional[List[str]] → Optional[List[AgentId]] - block_ids: Optional[List[str]] → Optional[List[BlockId]] This ensures malformed IDs are rejected with 422 validation errors instead of causing 500 database errors. 🤖 Generated with [Letta Code](https://letta.com) Co-Authored-By: Letta <noreply@letta.com> * chore: regenerate API spec and SDK --------- Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -34392,7 +34392,12 @@
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 42,
|
||||
"minLength": 42,
|
||||
"pattern": "^agent-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
|
||||
"description": "The ID of the agent in the format 'agent-<uuid4>'",
|
||||
"examples": ["agent-123e4567-e89b-42d3-8456-426614174000"]
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
@@ -34408,7 +34413,12 @@
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 42,
|
||||
"minLength": 42,
|
||||
"pattern": "^block-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
|
||||
"description": "The ID of the block in the format 'block-<uuid4>'",
|
||||
"examples": ["block-123e4567-e89b-42d3-8456-426614174000"]
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
@@ -34534,7 +34544,12 @@
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 42,
|
||||
"minLength": 42,
|
||||
"pattern": "^agent-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
|
||||
"description": "The ID of the agent in the format 'agent-<uuid4>'",
|
||||
"examples": ["agent-123e4567-e89b-42d3-8456-426614174000"]
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
@@ -34550,7 +34565,12 @@
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 42,
|
||||
"minLength": 42,
|
||||
"pattern": "^block-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
|
||||
"description": "The ID of the block in the format 'block-<uuid4>'",
|
||||
"examples": ["block-123e4567-e89b-42d3-8456-426614174000"]
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
@@ -34614,7 +34634,12 @@
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 42,
|
||||
"minLength": 42,
|
||||
"pattern": "^agent-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
|
||||
"description": "The ID of the agent in the format 'agent-<uuid4>'",
|
||||
"examples": ["agent-123e4567-e89b-42d3-8456-426614174000"]
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
@@ -34630,7 +34655,12 @@
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 42,
|
||||
"minLength": 42,
|
||||
"pattern": "^block-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
|
||||
"description": "The ID of the block in the format 'block-<uuid4>'",
|
||||
"examples": ["block-123e4567-e89b-42d3-8456-426614174000"]
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
|
||||
@@ -5,6 +5,7 @@ from pydantic import Field
|
||||
|
||||
from letta.schemas.enums import PrimitiveType
|
||||
from letta.schemas.letta_base import LettaBase
|
||||
from letta.validators import AgentId, BlockId
|
||||
|
||||
|
||||
class IdentityType(str, Enum):
|
||||
@@ -57,8 +58,8 @@ class IdentityCreate(LettaBase):
|
||||
name: str = Field(..., description="The name of the identity.")
|
||||
identity_type: IdentityType = Field(..., description="The type of the identity.")
|
||||
project_id: Optional[str] = Field(None, description="The project id of the identity, if applicable.")
|
||||
agent_ids: Optional[List[str]] = Field(None, description="The agent ids that are associated with the identity.", deprecated=True)
|
||||
block_ids: Optional[List[str]] = Field(None, description="The IDs of the blocks associated with the identity.", deprecated=True)
|
||||
agent_ids: Optional[List[AgentId]] = Field(None, description="The agent ids that are associated with the identity.", deprecated=True)
|
||||
block_ids: Optional[List[BlockId]] = Field(None, description="The IDs of the blocks associated with the identity.", deprecated=True)
|
||||
properties: Optional[List[IdentityProperty]] = Field(None, description="List of properties associated with the identity.")
|
||||
|
||||
|
||||
@@ -67,8 +68,8 @@ class IdentityUpsert(LettaBase):
|
||||
name: str = Field(..., description="The name of the identity.")
|
||||
identity_type: IdentityType = Field(..., description="The type of the identity.")
|
||||
project_id: Optional[str] = Field(None, description="The project id of the identity, if applicable.")
|
||||
agent_ids: Optional[List[str]] = Field(None, description="The agent ids that are associated with the identity.", deprecated=True)
|
||||
block_ids: Optional[List[str]] = Field(None, description="The IDs of the blocks associated with the identity.", deprecated=True)
|
||||
agent_ids: Optional[List[AgentId]] = Field(None, description="The agent ids that are associated with the identity.", deprecated=True)
|
||||
block_ids: Optional[List[BlockId]] = Field(None, description="The IDs of the blocks associated with the identity.", deprecated=True)
|
||||
properties: Optional[List[IdentityProperty]] = Field(None, description="List of properties associated with the identity.")
|
||||
|
||||
|
||||
@@ -76,8 +77,8 @@ class IdentityUpdate(LettaBase):
|
||||
identifier_key: Optional[str] = Field(None, description="External, user-generated identifier key of the identity.")
|
||||
name: Optional[str] = Field(None, description="The name of the identity.")
|
||||
identity_type: Optional[IdentityType] = Field(None, description="The type of the identity.")
|
||||
agent_ids: Optional[List[str]] = Field(None, description="The agent ids that are associated with the identity.", deprecated=True)
|
||||
block_ids: Optional[List[str]] = Field(None, description="The IDs of the blocks associated with the identity.", deprecated=True)
|
||||
agent_ids: Optional[List[AgentId]] = Field(None, description="The agent ids that are associated with the identity.", deprecated=True)
|
||||
block_ids: Optional[List[BlockId]] = Field(None, description="The IDs of the blocks associated with the identity.", deprecated=True)
|
||||
properties: Optional[List[IdentityProperty]] = Field(None, description="List of properties associated with the identity.")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user