Bug fixes related to file uploads. Fixing id_random int vs str confusion. For account and for hosted_file.
This commit is contained in:
@@ -15,9 +15,9 @@ class Hosted_File_Base(BaseModel):
|
||||
log.debug(locals())
|
||||
|
||||
# --- Standardized Vision IDs (Strings) ---
|
||||
id: Optional[str] = Field(None, **base_fields['hosted_file_id_random'])
|
||||
hosted_file_id: Optional[str] = Field(None, **base_fields['hosted_file_id_random'])
|
||||
account_id: Optional[str] = Field(None, **base_fields['account_id_random'])
|
||||
id: Optional[Union[int, str]] = Field(None, **base_fields['hosted_file_id_random'])
|
||||
hosted_file_id: Optional[Union[int, str]] = Field(None, **base_fields['hosted_file_id_random'])
|
||||
account_id: Optional[Union[int, str]] = Field(None, **base_fields['account_id_random'])
|
||||
|
||||
hash_sha256: Optional[str]
|
||||
title: Optional[str]
|
||||
@@ -69,17 +69,17 @@ class Hosted_File_Base(BaseModel):
|
||||
"""
|
||||
# 1. Map Random Strings to Clean Names
|
||||
if rid := values.get('id_random') or values.get('hosted_file_id_random'):
|
||||
values['id'] = rid
|
||||
values['hosted_file_id'] = rid
|
||||
# Only set if not already a valid integer
|
||||
if not isinstance(values.get('id'), int):
|
||||
values['id'] = rid
|
||||
if not isinstance(values.get('hosted_file_id'), int):
|
||||
values['hosted_file_id'] = rid
|
||||
|
||||
if a_rid := values.get('account_id_random'):
|
||||
values['account_id'] = a_rid
|
||||
# Only set if not already a valid integer
|
||||
if not isinstance(values.get('account_id'), int):
|
||||
values['account_id'] = a_rid
|
||||
|
||||
# 2. Prevent "Collision Population"
|
||||
for k in ['id', 'account_id']:
|
||||
if k in values and not isinstance(values[k], str):
|
||||
del values[k]
|
||||
|
||||
return values
|
||||
|
||||
class Config:
|
||||
|
||||
Reference in New Issue
Block a user