Skip to content

Fix: Save dialog 500 error when obj is dict in get_lti_id#19

Open
ImranFarhat01 wants to merge 1 commit into
FOSSEE:developfrom
ImranFarhat01:fix/save-dialog-clean
Open

Fix: Save dialog 500 error when obj is dict in get_lti_id#19
ImranFarhat01 wants to merge 1 commit into
FOSSEE:developfrom
ImranFarhat01:fix/save-dialog-clean

Conversation

@ImranFarhat01

Copy link
Copy Markdown

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

  • Opened the Save dialog, entered a title, clicked SAVE
  • Save request now returns 200 with a valid JSON response (lti_id: null)
  • Verified no 500 error occurs

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant