Fix: coupling in internal workflows endpoints
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you receive complimentary access to GitLab Duo.
What does this MR do and why?
Fix: coupling in internal workflows endpoints
The render_response helper in workflows_internal.rb
was directly using response.reason
from services as HTTP status codes. This violated the Service Response pattern, which states that service objects should return semantic reasons rather than HTTP status codes.
Changes Made
-
Service Layer (
revoke_token_service.rb
): Service now returns semantic reason :invalid_token when token validation fails -
API Endpoint Helper (
workflows_internal.rb
): Helper now maps semantic reasons to appropriate HTTP status codes -
Tests (
workflows_internal_spec.rb
): Updated tests to verify the reason-to-status mapping works correctly.
Fixes #567346
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.