Skip to content

Bug: contact topic answers are permanently deleted when a case contact is soft-deleted #6837

@cliftonmcintosh

Description

@cliftonmcintosh

Impacted User Types

All users who can delete and restore case contacts — admins and supervisors.

Environment

Any environment. This is a data loss issue in the Rails model layer, not specific to a browser or deployment.

Current Behavior

When a case contact is deleted, the contact_topic_answers associated with it are permanently removed from the database. If the case contact is later restored, it will be missing all of its topic answers.

This happens because CaseContact uses acts_as_paranoid for soft deletes, but ContactTopicAnswer does not. The dependent: :destroy cascade from a paranoia soft-delete issues a real SQL DELETE on contact_topic_answers, not a soft delete.

The restore(recursive: true) call in CaseContactsController#restore only recovers records that were themselves soft-deleted — so permanently deleted contact_topic_answers cannot be recovered.

Relevant code in app/models/case_contact.rb:

acts_as_paranoid
has_many :contact_topic_answers, dependent: :destroy

Expected Behavior

Deleting a case contact should soft-delete its contact_topic_answers as well, so that restoring the case contact also restores the topic answers.

How to Replicate

  1. Log in as an admin
  2. Navigate to a casa case (e.g. /casa_cases/:id)
  3. Create a case contact and fill in at least one contact topic answer
  4. Delete the case contact
  5. Return to the casa case page — the deleted contact appears with [DELETE] prefixed to its name
  6. Observe that the contact topic answers are no longer shown for the deleted contact
  7. Click the "undelete" button to restore the case contact
  8. Observe that the topic answers are still not shown on the restored contact
Screen recording of bug
Screen.Recording.2026-04-09.at.16.03.50.mov

How to access the QA site

Login Details:
Link to QA site

Login Emails:

Password for all users: 12345678

Questions? Join Slack!

We highly recommend that you join us in slack #casa channel to ask questions quickly. And discord for office hours (currently Tuesday 5-7pm Pacific), stakeholder news, and upcoming new issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Help WantedThis is a special label that enables github to showcase issues that want helpType: Bug

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions