Skip to content

fix: handle restore warning responses in upload UI#421

Open
lil-aditya wants to merge 1 commit intoEAPD-DRB:mainfrom
lil-aditya:fix/upload-restore-warning-flow
Open

fix: handle restore warning responses in upload UI#421
lil-aditya wants to merge 1 commit intoEAPD-DRB:mainfrom
lil-aditya:fix/upload-restore-warning-flow

Conversation

@lil-aditya
Copy link
Copy Markdown
Contributor

Linked issue

Existing related work reviewed

Overlap assessment

Why this PR should proceed

  • It fixes a real user-visible bug where successful legacy restores appear to fail in the UI
  • The change is narrow, low-risk, and isolated to the upload success handler
  • It improves correctness without changing backend contracts or adding broad refactors
  • It restores expected behavior for legacy model uploads while preserving warning-only handling for non-restoring cases such as "already exists"

Summary

  • What changed:
    • Added a small shared success helper for case-restore responses in WebAPP/Classes/Base.Class.js
    • Updated the upload success callback to handle three cases explicitly:
      • success
      • warning with message_warning for successful legacy restores
      • warning without restore side effects, such as "already exists"
    • Added a defensive guard for malformed / unexpected upload responses
  • Why:
    • The backend intentionally returns status_code: "warning" for older model restores
    • The previous frontend code had an empty warning branch, so restore completion was not reflected in the UI
    • Users could therefore restore a legacy model successfully but see no appended model, no modal close, and no migration guidance

Validation

  • Tests added/updated (or not applicable)
  • Validation steps documented

Validation details:

  • Ran a targeted Node-based harness against the actual upload success callback logic
  • Verified expected behavior for:
    • success: model appended, success message shown, modal closed
    • legacy restore warning: model appended, success message shown, upgrade warning shown, modal closed
    • non-restoring warning: warning shown only, no UI mutation
    • error: danger message shown

Example validation output:

success: [["append","Demo"],["success","Upload response","ok",null],["modal","toggle"]]
warning_restore: [["append","Legacy"],["success","Upload response","uploaded",null],["warningOsy","needs update"],["modal","toggle"]]
warning_exists: [["warning","Upload response","already exists",null]]
error: [["danger","Upload response","bad zip",null]]

Copilot AI review requested due to automatic review settings April 6, 2026 15:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the restore/upload UI so that backend “legacy restore” responses returned as status_code: "warning" are treated as successful restores (append model, close modal) while still surfacing the warning guidance to the user.

Changes:

  • Added a shared helper (handleCaseRestoreSuccess) to centralize “restore succeeded” UI actions.
  • Updated the Dropzone upload success handler to distinguish:
    • success
    • warning with message_warning (legacy restore success + upgrade warning)
    • warning without restore side effects (warning-only)
  • Added a guard for missing/empty response.response[0] payloads.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Message.bigBoxWarning("Upload response", result['message'], null);
}
} else if (result['status_code'] == 'error') {
Message.bigBoxDanger("Upload response", result['message'], null);
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The success callback has no fallback for unexpected/malformed status_code values (or a missing status_code). In that case the handler will silently do nothing, which undermines the new defensive handling. Consider adding a final else that shows a danger/warning message (and optionally logs the payload) so users aren’t left with no UI feedback when the response shape changes.

Suggested change
Message.bigBoxDanger("Upload response", result['message'], null);
Message.bigBoxDanger("Upload response", result['message'], null);
} else {
console.warn('Unexpected upload response status_code', result);
Message.bigBoxWarning("Upload response", "Upload completed but returned an unexpected status.", null);

Copilot uses AI. Check for mistakes.
@lil-aditya
Copy link
Copy Markdown
Contributor Author

@SeaCelo @autibet please review this.

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.

[Bug] Legacy model restore warnings are ignored by the upload UI

2 participants