Skip to content

fix: return 200 on duplicate save instead of crash code "500"#33

Open
Aditya-Sarna wants to merge 1 commit into
FOSSEE:developfrom
Aditya-Sarna:esim
Open

fix: return 200 on duplicate save instead of crash code "500"#33
Aditya-Sarna wants to merge 1 commit into
FOSSEE:developfrom
Aditya-Sarna:esim

Conversation

@Aditya-Sarna

Copy link
Copy Markdown

Problem

  • Re-saving the same circuit (no changes) hit duplicate detection but returned 500
  • Response used input serializer .dataget_lti_id() got a dict instead of a model → AttributeError
  • Frontend showed "Saved Successfully" but save actually failed

Fix

  • Serialize the existing DB record: StateSaveSerializer(queryset).data
  • Use validated_data for name/description updates
  • Return 200 with "duplicate": true

Testing

  • First save → 200, URL gets id=...
  • Same circuit saved again → 200 with "duplicate": true (was 500)
  • Verified via browser Network tab and POST /api/save curl

Serialize the existing StateSave record when duplicate content is detected so get_lti_id receives a model instance rather than validated request data.
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