Skip to content

Fix: recreating an LTI app after deletion fails with a 400 error#29

Open
ImranFarhat01 wants to merge 1 commit into
FOSSEE:developfrom
ImranFarhat01:fix/lti-scored-field-reset
Open

Fix: recreating an LTI app after deletion fails with a 400 error#29
ImranFarhat01 wants to merge 1 commit into
FOSSEE:developfrom
ImranFarhat01:fix/lti-scored-field-reset

Conversation

@ImranFarhat01

Copy link
Copy Markdown

Problem

After deleting an LTI app, creating a new one for the same circuit
failed with a 400 error, with no feedback shown to the user beyond a
generic console error.

Root Cause

The component rebuilds its state from scratch after a successful
delete, but the rebuilt object didn't match the shape of a genuinely
fresh, working state in two ways:

  • It omitted a required boolean field entirely, which then got
    silently dropped from the request body
  • It set the score field to an empty string, which the backend
    rejects as "not a valid number" (it allows null, but not an
    empty string)

Fix

  • Restored the missing boolean field to match the component's
    actual initial default
  • Changed the score field from an empty string to null, matching
    what the backend explicitly allows

Testing

  • Created an LTI app, deleted it, created a new one for the same
    circuit without touching any optional fields: succeeds where it
    previously failed

…elete

After deleting an LTI app, creating a new one for the same circuit
failed with a 400 error, with no feedback shown to the user beyond
a generic console error.

Root cause: handleDeleteLTIApp rebuilds the component's ltiDetails
state from scratch after a successful delete, but the rebuilt
object didn't match the shape of a genuinely fresh, working state
in two ways:
- It omitted the scored field entirely. Once scored became
  undefined, it stayed undefined unless the user manually toggled
  the checkbox, and got silently dropped from the request body
  (the backend requires this field).
- It set score to an empty string. The backend's score field
  allows null but rejects an empty string as 'not a valid number',
  and the empty string only avoided this on a fresh page load by
  coincidence (an unrelated code path there replaces the whole
  state object without a score key at all, rather than setting it
  to an empty string).

Fix:
- Added scored: true to match the component's actual initial state
- Changed score from '' to null, matching what the backend's score
  field explicitly allows

Testing:
- Created an LTI app, deleted it, created a new one for the same
  circuit without touching the Score or Scored fields: succeeds
  (201) where it previously failed (400)
@ImranFarhat01 ImranFarhat01 force-pushed the fix/lti-scored-field-reset branch from d8d46d5 to 03c3221 Compare June 19, 2026 18:30
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