Bug fixes related to file uploads. Fixing id_random int vs str confusion. For account and for hosted_file.

This commit is contained in:
Scott Idem
2026-01-22 16:01:23 -05:00
parent 988775b9dd
commit 48d9e38c39
3 changed files with 48 additions and 28 deletions

View File

@@ -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: