Replies: 7 comments
-
This is not related to fastapi but to python itself. You iterate over dict and change it in the loop. Something like
If you need to modify the dict (add or delete any key), you have to iterate over copy of the iterated container / dict, as follows:
|
Beta Was this translation helpful? Give feedback.
-
@ondrejkajinek It's not my code causing the error. The problem lies more low level in fastapi |
Beta Was this translation helpful? Give feedback.
-
Yes, line 70 is the loop where you iterate over the dict, but inside the loop there is no dict modification, only key and value encoding and those encoded values are pushed to resulting dict. I'm suspecting your code to contain some custom json serializer that modify the value. Can you check if this is not the case? But those are just guesses. |
Beta Was this translation helpful? Give feedback.
-
Nope, I don't have any custom json serializer in my code. |
Beta Was this translation helpful? Give feedback.
-
Could you please provide MWE that causes the error? |
Beta Was this translation helpful? Give feedback.
-
@ondrejkajinek I don't have enough context, cause the error traceback doesn't point to any part of my code. 😅 |
Beta Was this translation helpful? Give feedback.
-
First Check
Commit to Help
Example Code
Description
The error is occurring rarely and I couldn't identify any patterns. When I resent the same request, after a few seconds to the server the error didn't appear.
Operating System
Linux
Operating System Details
No response
FastAPI Version
0.62.0
Python Version
Python 3.7.6
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions