kernelci / kernelci-api

KernelCI API - Database - Pub/Sub
GNU Lesser General Public License v2.1
9 stars 17 forks source link

Fix `pydantic` v2 warnings #560

Open JenySadadia opened 3 weeks ago

JenySadadia commented 3 weeks ago

Receiving pydantic warning on kci user group join command:

kernelci-api          | INFO:     172.21.0.1:46482 - "GET /latest/users?username=test_user&limit=100&offset=0 HTTP/1.1" 200 OK
kernelci-api          | /home/kernelci/.local/lib/python3.11/site-packages/pydantic/main.py:390: UserWarning: Pydantic serializer warnings:
kernelci-api          |   Expected `str` but got `UserGroup` with value `UserGroup(id=ObjectId('64...16ad'), name='kernelci')` - serialized value may not be as expected
kernelci-api          |   Expected `str` but got `UserGroup` with value `UserGroup(id=ObjectId('67...a017faa3'), name='test')` - serialized value may not be as expected
kernelci-api          |   return self.__pydantic_serializer__.to_python(
kernelci-api          | User 670e4486de0eba06b43e645f test_user has been updated.
kernelci-api          | INFO:     172.21.0.1:46492 - "PATCH /latest/user/670e4486de0eba06b43e645f HTTP/1.1" 200 OK

The warnings are also observed while running unit tests.

JenySadadia commented 2 days ago

@nuclearcat reported pydantic warnings below:

INFO:     10.224.0.101:55470 - "GET /latest/nodes?parent=6733238c68b6090bcedcc978&limit=100&offset=0 HTTP/1.1" 200 OK
/usr/local/lib/python3.11/site-packages/pydantic/main.py:390: UserWarning: Pydantic serializer warnings:
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  Expected `url` but got `str` with value `'https://kciapistagingsto...GGQivo89HKZbD78gcxvc%3D'` - serialized value may not be as expected
  PydanticSerializationUnexpectedValue: Expected `url` but got `str` with value `'https://git.kernel.org/p...t/sashal/linus-next.git'` - serialized value may not be as expected
  PydanticSerializationUnexpectedValue: Expected `url` but got `str` with value `'https://git.kernel.org/p...t/sashal/linus-next.git'` - serialized value may not be as expected
  return self.__pydantic_serializer__.to_python(