Skip to content

Fix re-adding investigation after deletion - #4190

Merged
praseodym merged 5 commits into
mainfrom
4172-investigation-delete-readd
Nov 2, 2026
Merged

praseodym merged 5 commits into
mainfrom
4172-investigation-delete-readd

Conversation

@praseodym

Copy link
Copy Markdown
Contributor

What & why

When an investigation with corrected results was deleted, its data entry stayed behind. Adding a new investigation for the same polling station and concluding it then gave an internal server error. This is fixed by deleting any linked data entry when an investigation is deleted. Fixes #4172.

How to test

  1. Log in as coördinator GSB 1.
  2. Go to Corrigendum Gemeenteraad Juinen 2026 (GSB CSO) -> Aangevraagde onderzoeken.
  3. Delete the investigation for "Test ander gebouw".
  4. Create a new investigation for "Test ander gebouw" and save it.

This works with this PR. On main it gives an internal server error.

Reviewer notes

  • The first commit adds tests (they fail on main), the second commit fixes the issue and makes the tests pass.
  • delete_investigation_for_polling_station deletes any linked data entry as well. Both the investigation delete endpoint and the polling station delete endpoint use it.
  • investigation_repo::delete returns a DataEntryAlreadyLinked error if the polling station still has a data entry, to prevent this issue from reoccurring in another code path.
  • Later: move the delete helpers from api/ to service/.

@praseodym praseodym self-assigned this Oct 27, 2026
@praseodym praseodym added backend Issues or pull requests that relate to the backend needs-backport/1.2 Needs backporting to the 1.2 release branch labels Oct 27, 2026
@praseodym
praseodym requested a review from a team as a code owner October 27, 2026 20:44
@jschuurk-kr

Copy link
Copy Markdown
Contributor

In case someone else goes down the same road: I was expecting the fix to include a modal about removing the data entry. It doesn't include it because the modal already exists:
image

Comment thread backend/src/api/investigation.rs Resolved

@oliver3 oliver3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No comments that are worth another review cycle

@jschuurk-kr

Copy link
Copy Markdown
Contributor

Tested a variety of scenarios of deleting investigations, data entries and polling stations. Did not find any issues causing incorrect data states.

Did discover it's a good idea to fetch data entry status more often on the investigation pages. Created PR #4218 for that.

@praseodym
praseodym added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit 472d08d Nov 2, 2026
23 checks passed
@praseodym
praseodym deleted the 4172-investigation-delete-readd branch November 2, 2026 09:34
@praseodym praseodym removed the needs-backport/1.2 Needs backporting to the 1.2 release branch label Nov 2, 2026

This branch was successfully deployed

1 active deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Issues or pull requests that relate to the backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server error after deleting an investigation, then added a new one to the same polling station

4 participants