Fix: Save dialog 500 error when obj is dict in get_lti_id#19
Open
ImranFarhat01 wants to merge 1 commit into
Open
Fix: Save dialog 500 error when obj is dict in get_lti_id#19ImranFarhat01 wants to merge 1 commit into
ImranFarhat01 wants to merge 1 commit into
Conversation
Save dialog SAVE button triggered a 500 Internal Server Error. get_lti_id() in StateSaveSerializer and SaveListSerializer called obj.save_id assuming obj is always a model instance, but it can also be an OrderedDict/dict in some serialization contexts, which has no save_id attribute. Add isinstance(obj, dict) check in both get_lti_id() methods to return None early in that case. Note: the related Ctrl+S crash (gridRef.current null) is already fixed differently upstream (exportImage null guard), so this PR only addresses the backend 500 error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Clicking SAVE in the Save dialog triggered a 500 Internal Server Error.
Root Cause
get_lti_id() in StateSaveSerializer and SaveListSerializer (saveAPI/serializers.py)
accesses obj.save_id, assuming obj is always a model instance. In some
serialization contexts obj can be an OrderedDict/dict, which has no save_id
attribute, causing an AttributeError -> 500.
Fix
Add an isinstance(obj, dict) check at the start of both get_lti_id() methods
to return None early when obj is a dict.
Testing
Note
A related frontend crash (Ctrl+S before grid initialization) was found
alongside this bug during testing, but it is already fixed differently
on develop (exportImage null guard in SchematicToolbar.js), so this PR
is scoped to only the backend serializer fix.