Skip to content

feat: Implement API to GDPR delete users#3224

Open
Janis4411 wants to merge 1 commit intomainfrom
jv/SODEV-2997-Implement-API-to-GDPR-delete-users
Open

feat: Implement API to GDPR delete users#3224
Janis4411 wants to merge 1 commit intomainfrom
jv/SODEV-2997-Implement-API-to-GDPR-delete-users

Conversation

@Janis4411
Copy link
Copy Markdown
Contributor

This PR introduces a possible way to GDPR delete users via a API.

If we delete a user on openHPI we also have to delete the user on codeocean. Previously this was handled via a rake task that has to be triggered manually.

Part of SODEV-2997

@Janis4411 Janis4411 requested a review from arkirchner April 16, 2026 13:25
@Janis4411 Janis4411 force-pushed the jv/SODEV-2997-Implement-API-to-GDPR-delete-users branch from 85f5e83 to 4c3c10a Compare April 16, 2026 13:26
Comment thread app/controllers/api/internal/users/deletions_controller.rb Fixed
Comment thread app/controllers/api/internal/users/deletions_controller.rb Outdated
Comment thread app/jobs/user_cleanup_job.rb Outdated
@Janis4411 Janis4411 marked this pull request as draft April 16, 2026 13:34
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.40%. Comparing base (7876111) to head (62fa41c).

Files with missing lines Patch % Lines
...rollers/api/internal/users/deletions_controller.rb 92.30% 1 Missing ⚠️
lib/tasks/gdpr_delete.rake 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3224      +/-   ##
==========================================
+ Coverage   70.33%   70.40%   +0.07%     
==========================================
  Files         214      216       +2     
  Lines        6839     6860      +21     
==========================================
+ Hits         4810     4830      +20     
- Misses       2029     2030       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Janis4411 Janis4411 force-pushed the jv/SODEV-2997-Implement-API-to-GDPR-delete-users branch 3 times, most recently from 3238780 to 9988915 Compare April 20, 2026 07:57
Comment thread app/controllers/api/api_controller.rb Fixed
Comment thread app/controllers/api/api_controller.rb Fixed
@Janis4411 Janis4411 force-pushed the jv/SODEV-2997-Implement-API-to-GDPR-delete-users branch from 9988915 to cb82a61 Compare April 20, 2026 08:23
@Janis4411 Janis4411 self-assigned this Apr 20, 2026
@Janis4411 Janis4411 marked this pull request as ready for review April 20, 2026 09:53
Comment thread app/jobs/user_cleanup_job.rb Outdated
Comment thread app/controllers/api/internal/users/deletions_controller.rb Outdated
Comment thread app/controllers/api/api_controller.rb Outdated
Comment thread app/controllers/api/internal/users/deletions_controller.rb Outdated
Comment thread app/controllers/api/internal/users/deletions_controller.rb Outdated
Comment thread app/jobs/user_cleanup_job.rb Outdated
@Janis4411 Janis4411 force-pushed the jv/SODEV-2997-Implement-API-to-GDPR-delete-users branch from cb82a61 to b7bfbd7 Compare April 20, 2026 11:57
Comment on lines +14 to +16
end

head :ok
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The user deletion API endpoint always returns a success status, even if the underlying user.soft_delete! operation fails to update the database.
Severity: HIGH

Suggested Fix

Check the boolean return value of user.soft_delete!. If it returns false, respond with an appropriate error status, such as head :unprocessable_entity, instead of head :ok. This ensures that failures in the soft-deletion process are correctly reported to the API client.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: app/controllers/api/internal/users/deletions_controller.rb#L14-L16

Potential issue: The `DeletionsController#delete` action calls `user.soft_delete!`,
which returns `false` if the database update fails. The controller does not check this
return value and unconditionally returns an `HTTP 200 OK` status. This misleads the
calling service (e.g., openHPI) into believing a GDPR-mandated user deletion was
successful when it actually failed. This behavior contradicts the established
error-handling pattern in an existing Rake task (`gdpr_delete.rake`), which explicitly
checks for failures from the same method, indicating that failures are an expected
possibility that must be handled.

This is a possible way to GDPR delete users via a API. The background
is that if we delete a user on openhpi we also want to delete the user
on codeocean.

Part of SODEV-2997
@Janis4411 Janis4411 force-pushed the jv/SODEV-2997-Implement-API-to-GDPR-delete-users branch from b7bfbd7 to 62fa41c Compare April 20, 2026 12:25
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.

3 participants