-
-
Notifications
You must be signed in to change notification settings - Fork 0
BUG: issues with encoding and null field updates #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
82ea8bb
44a2ebc
8cbd939
9114d81
cbefff8
b721e28
2f36252
597aad0
ec9a552
0286681
476f88b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -73,8 +73,30 @@ def default(self, o): | |||||||
mutate_self=False, | ||||||||
) | ||||||||
if isinstance(obj, Flight): | ||||||||
obj._Flight__evaluate_post_process() | ||||||||
solution = np.array(obj.solution) | ||||||||
try: | ||||||||
evaluate_post_process = getattr(obj, '_Flight__evaluate_post_process', None) | ||||||||
|
||||||||
# Check if it's corrupted (numpy array instead of cached_property) | ||||||||
if isinstance(evaluate_post_process, np.ndarray): | ||||||||
GabrielBarberini marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
try: | ||||||||
delattr(obj, '_Flight__evaluate_post_process') | ||||||||
|
||||||||
restored_method = getattr(obj, '_Flight__evaluate_post_process', None) | ||||||||
|
restored_method = getattr(obj, '_Flight__evaluate_post_process', None) | |
# Access the property via the class descriptor to restore it correctly | |
restored_method = type(obj)._Flight__evaluate_post_process.__get__(obj, type(obj)) |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wdyt @aasitvora99 ?
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguably this is a tautology.
If it is callable it will always pass the first check.
Maybe just reduce it to if callable(obj)
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
Only callable check is enough
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify that including None-valued fields doesn't cause unintended data overwrites.
Changing
exclude_none=False
means None-valued fields are now included in update payloads. If the intent is partial updates (only updating provided fields), this could overwrite existing non-null database values with None.For example, if a client sends
FlightModel(environment=some_env, rocket=None)
, the rocket field would be set to None in the database even if a rocket was previously associated.Confirm that one of the following is true:
update_by_id
implementation filters out None values before persistingRun the following script to examine the
update_by_id
implementation:🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 7605
Filter out None-valued fields in the update payload
update_by_id
applies{"$set": data}
directly, so any keys withNone
frommodel_dump(exclude_none=False)
will overwrite existing fields withnull
. Usemodel_dump(exclude_none=True)
or manually removeNone
entries for true partial updates.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aasitvora99 why is this necessary? I would prefer we drop the null fields unless their null state is actually used by the lib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.