[M-16] Two incompatible error contracts mixed per endpoint (REST {error,reason} vs ICD {iErrorCode} with HTTP-200 failures) #28

Closed
opened 2026-11-14 18:28:54 +01:00 by amiryahaya · 1 comment
Owner

Finding

Enrollment returns REST-style errors with 400/503; renewal/revoke return ICD-style iErrorCode with HTTP 200 for failures like -101/RN102; RequireJwt puts pseudo-codes "400"/"402" in iErrorCode inside a real 401.

Evidence

  • lib/mdid_ws_web/controllers/cert_management_controller.ex:25-71 vs :131-141
  • lib/mdid_ws_web/plugs/require_jwt.ex:40-47

Impact

Consumers cannot build one error-handling path; ambiguous success/failure semantics.

Fix

  • Define one error-shape module used by every action (choose the ICD contract if that's the integration spec) and stop overloading iErrorCode with HTTP codes

Line numbers refer to the initial import commit 282cb11. Source: comprehensive audit, 2026-11-12 (first review of this codebase).

## Finding Enrollment returns REST-style errors with 400/503; renewal/revoke return ICD-style `iErrorCode` with HTTP 200 for failures like -101/RN102; RequireJwt puts pseudo-codes "400"/"402" in iErrorCode inside a real 401. ## Evidence - `lib/mdid_ws_web/controllers/cert_management_controller.ex:25-71` vs `:131-141` - `lib/mdid_ws_web/plugs/require_jwt.ex:40-47` ## Impact Consumers cannot build one error-handling path; ambiguous success/failure semantics. ## Fix - [ ] Define one error-shape module used by every action (choose the ICD contract if that's the integration spec) and stop overloading iErrorCode with HTTP codes _Line numbers refer to the initial import commit `282cb11`. Source: comprehensive audit, 2026-11-12 (first review of this codebase)._
Author
Owner

Verified fixed on main (1b6216b): all /api/v1/cert_mgmt errors rendered by ApiError as iErrorCode/sErrorMessage (B4).

Verified fixed on main (1b6216b): all /api/v1/cert_mgmt errors rendered by ApiError as iErrorCode/sErrorMessage (B4).
Sign in to join this conversation.
No description provided.