ThingSettings are passed a dictionary not a BaseModel of the correct type when loading from JSON
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start by creating a ThingSetting whose type is a BaseModel, then trace the JSON loading path to the setter. Verify the current value is a dictionary and confirm that the completed fix passes an instance of the declared BaseModel type to the setter.
Written by the indexing model from the issue text.
Description
Describe the bug
When saving everything is converted to JSON, if the type for a setting is a BaseModel it is serialised to a JSON. For all standard Python types they also convert easily to JSON via being put in a dictionary of settings.
On load the standard python types are loaded correctly, but the BaseModel is loaded as a dictionary. This means the setter for the ThingSetting is passed a Dictionary not a BaseModel of the correct type. This is currently handled in the OpenFlexure Microscope by explicitly using a setter for the anything that is a base model and type checking for dictionaries.
To Reproduce
Create a ThingSetting with a BaseModel as the type
Expected behaviour
The server should deserialise the data back into the correct type before sending to the setter.
System:
- OS: Ubuntu 24.04 and OpenFlexure Raspian
- Python version 3.11
- Version 0.0.10
- Dominant language
- Python
- Stars
- 9
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from labthings/labthings-fastapi
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
labthings/labthings-fastapi#405 ·
-
drop-python-version
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
labthings/labthings-fastapi#354 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
labthings/labthings-fastapi#312 · 1 comment ·
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 65/100
labthings/labthings-fastapi#407 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
labthings/labthings-fastapi#404 · 2 comments ·
All issues in labthings/labthings-fastapi
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
spec-kitty/spec-kitty#5319 ·
Maintainers usually reply within 1 day
-
backend::vllm diffusion multimodal
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
openai/openai-agents-python#5229 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day