merge-api / merge-python-client

The Python SDK for accessing various Merge Unified APIs
Other
6 stars 10 forks source link

Latest version broken: Validation Error for File PermissionsRequest #90

Closed lucasgadams closed 2 months ago

lucasgadams commented 2 months ago

Hi team, there seems to be an issue with the latest release. It looks like the PermissionRequest in filestorage does not have all of the existing fields defined on the model, and also has extra = pydantic_v1.Extra.forbid. This is making all calls to files.list fail.

mergepythonclient 1.0.10 pydantic 2.7.4 python: 3.12.4

In [3]: res = await self.client.filestorage.files.list()
---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
Cell In[3], line 1
----> 1 res = await self.client.filestorage.files.list()

File ~/Repos/materia-services/.venv/lib/python3.12/site-packages/merge/resources/filestorage/resources/files/client.py:456, in AsyncFilesClient.list(self, created_after, created_before, cursor, drive_id, expand, folder_id, include_deleted_data, include_remote_data, mime_type, modified_after, modified_before, name, page_size, remote_id, request_options)
    434 _response = await self._client_wrapper.httpx_client.request(
    435     "filestorage/v1/files",
    436     method="GET",
   (...)
    453     request_options=request_options,
    454 )
    455 if 200 <= _response.status_code < 300:
--> 456     return pydantic_v1.parse_obj_as(PaginatedFileList, _response.json())  # type: ignore
    457 try:
    458     _response_json = _response.json()

File ~/Repos/materia-services/.venv/lib/python3.12/site-packages/pydantic/v1/tools.py:38, in parse_obj_as(type_, obj, type_name)
     36 def parse_obj_as(type_: Type[T], obj: Any, *, type_name: Optional[NameFactory] = None) -> T:
     37     model_type = _get_parsing_type(type_, type_name=type_name)  # type: ignore[arg-type]
---> 38     return model_type(__root__=obj).__root__

File ~/Repos/materia-services/.venv/lib/python3.12/site-packages/pydantic/v1/main.py:341, in BaseModel.__init__(__pydantic_self__, **data)
    339 values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
    340 if validation_error:
--> 341     raise validation_error
    342 try:
    343     object_setattr(__pydantic_self__, '__dict__', values)

ValidationError: 420 validation errors for ParsingModel[PaginatedFileList]
__root__ -> results -> 0 -> permissions
  str type expected (type=type_error.str)
__root__ -> results -> 0 -> permissions
  value is not a valid dict (type=type_error.dict)
__root__ -> results -> 0 -> permissions -> 0
  str type expected (type=type_error.str)
__root__ -> results -> 0 -> permissions -> 0 -> created_at
  extra fields not permitted (type=value_error.extra)
__root__ -> results -> 0 -> permissions -> 0 -> id
  extra fields not permitted (type=value_error.extra)
__root__ -> results -> 0 -> permissions -> 0 -> modified_at
  extra fields not permitted (type=value_error.extra)
__root__ -> results -> 0 -> permissions -> 1
  str type expected (type=type_error.str)
__root__ -> results -> 0 -> permissions -> 1 -> created_at
  extra fields not permitted (type=value_error.extra)
__root__ -> results -> 0 -> permissions -> 1 -> id
  extra fields not permitted (type=value_error.extra)
__root__ -> results -> 0 -> permissions -> 1 -> modified_at
  extra fields not permitted (type=value_error.extra)
__root__ -> results -> 0 -> permissions -> 2
  str type expected (type=type_error.str)
__root__ -> results -> 0 -> permissions -> 2 -> created_at
  extra fields not permitted (type=value_error.extra)
  ....
dsinghvi commented 2 months ago

Hey @lucasgadams thanks for reporting this to us. We'll take a look shortly.

dsinghvi commented 2 months ago

@lucasgadams this should be fixed on the latest version 1.0.11. Apologies for the error!