-
Notifications
You must be signed in to change notification settings - Fork 4
Description
I've been getting my head around the API via the SDK and found the following issue when calling the get_current_user() method. I'm getting the following validation error:
{
detail: "Error calling OpenElectricity /v4/me endpoint: 2 validation errors for OpennemUserResponse
version
Field required [type=missing, input_value={'data': {'id': 'key_53tF...a': {'remaining': 497}}}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing
created_at
Field required [type=missing, input_value={'data': {'id': 'key_53tF...a': {'remaining': 497}}}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing"
}
This appears to be because the /v4/me endpoint doesn't return the version or created_at fields - but the validation has a hard requirement on this.
Solution to this could be to make those fields optional in the SDK - or add the fields to the API response.
Option 1: make fields optional
https://github.com/opennem/openelectricity-python/blob/4fabba7a7a0c93f762585a5b2027eab054a5a798/openelectricity/models/base.py#L13C1-L21C37
Option 2: update the API to return version and created_at
I've tried to have a little dig in to this code - but it's not obvious to me why it's not already returning this value based on:
- https://github.com/opennem/opennem/blob/c523daaa9900e4e4a687747fc91a8d49061c783d/opennem/api/app.py#L488-L489
- and https://github.com/opennem/opennem/blob/c523daaa9900e4e4a687747fc91a8d49061c783d/opennem/users/schema.py#L68-L69
- and https://github.com/opennem/opennem/blob/c523daaa9900e4e4a687747fc91a8d49061c783d/opennem/api/schema.py#L47-L53
However I did check via a curl request
curl -X GET "https://api.openelectricity.org.au/v4/me" -H "Authorization: Bearer your_api_key_here"
and it's returns the following format which confirms it's not adding the version and created_at fields:
{
"data":
{
"id":"key_XXXXX",
"full_name":"XXXX",
"email":"XXXX",
"owner_id":"XXXX",
"plan":"BASIC",
"meta":{"remaining":496}
}
}Hope this helps