Which version of Nextcloud are you using?
v34.0.0
Which version of PHP context_chat are you using?
v5.4.0-beta0
Which version of backend context_chat are you using?
v5.4.0-beta0
Nextcloud deployment method?
docker-compose
Describe the Bug
the whole batch of files/content provider documents fails if there is even one of the items in the list that has empty content or fails the validation for any field.
validation of a single item where empty content fails:
|
class CommonSourceItem(BaseModel): |
|
userIds: Annotated[list[str], AfterValidator(_validate_user_ids)] |
|
# source_id of the form "appId__providerId: itemId" |
|
reference: Annotated[str, AfterValidator(_validate_source_id)] |
|
title: str |
|
modified: int |
|
type: str |
|
provider: Annotated[str, AfterValidator(_validate_provider_id)] |
|
size: float |
|
|
|
@field_validator('modified', mode='before') |
|
@classmethod |
|
def validate_modified(cls, v): |
|
if isinstance(v, int): |
|
return v |
|
if isinstance(v, str): |
|
try: |
|
return int(v) |
|
except ValueError as e: |
|
raise ValueError(f'Invalid modified value: {v}') from e |
|
raise ValueError(f'Invalid modified type: {type(v)}') |
|
|
|
@field_validator('reference', 'title', 'type', 'provider') |
|
@classmethod |
|
def validate_strings_non_empty(cls, v): |
|
if not isinstance(v, str) or v.strip() == '': |
|
raise ValueError('Must be a non-empty string') |
|
return v.strip() |
|
|
|
@field_validator('size') |
|
@classmethod |
|
def validate_size(cls, v): |
|
if isinstance(v, int | float) and v >= 0: |
|
return float(v) |
|
raise ValueError(f'Invalid size value: {v}, must be a non-negative number') |
|
|
|
@model_validator(mode='after') |
|
def validate_type(self) -> Self: |
|
if self.reference.startswith(FILES_PROVIDER_ID) and self.type not in SUPPORTED_MIMETYPES: |
|
raise ValueError(f'Unsupported file type: {self.type} for reference {self.reference}') |
|
return self |
To Reproduce
/
PHP logs (Warning these might contain sensitive information)
No response
Ex-App logs (Warning these might contain sensitive information)
No response
Server logs (if applicable)
No response
Which version of Nextcloud are you using?
v34.0.0
Which version of PHP context_chat are you using?
v5.4.0-beta0
Which version of backend context_chat are you using?
v5.4.0-beta0
Nextcloud deployment method?
docker-compose
Describe the Bug
the whole batch of files/content provider documents fails if there is even one of the items in the list that has empty content or fails the validation for any field.
validation of a single item where empty content fails:
context_chat_backend/context_chat_backend/types.py
Lines 162 to 202 in fb25e86
To Reproduce
/
PHP logs (Warning these might contain sensitive information)
No response
Ex-App logs (Warning these might contain sensitive information)
No response
Server logs (if applicable)
No response