Skip to content

Fix/1286 transition rules unified - #1494

Open
Ayomide-codex wants to merge 2 commits into
Disciplr-Org:mainfrom
Ayomide-codex:fix/1286-transition-rules-unified
Open

Fix/1286 transition rules unified#1494
Ayomide-codex wants to merge 2 commits into
Disciplr-Org:mainfrom
Ayomide-codex:fix/1286-transition-rules-unified

Conversation

@Ayomide-codex

Copy link
Copy Markdown

Summary

This PR replaces the generic Error thrown during verifier profile audit action lookup with a dedicated, typed exception. This improves error handling by making internal inconsistencies between verifier status transition validation and audit action mapping explicit, allowing callers to distinguish this failure from unexpected server errors.

Changes Made

  • Added a dedicated typed exception for missing verifier audit action mappings.
  • Replaced the generic Error thrown in updateVerifierProfile with the new exception.
  • Updated error handling to propagate the typed exception through the existing application error flow.
  • Preserved existing behavior for valid verifier status transitions while improving diagnostics for inconsistent state/action mappings.
  • Improved error messaging to clearly identify the missing audit action for the affected status transition.

Files Updated

  • src/services/verifiers.ts
  • src/routes/adminVerifiers.ts (if required for explicit handling)
  • Error definitions
  • Related test files
  • Documentation (if applicable)

Testing

  • ✅ Added unit tests covering missing audit action mappings.
  • ✅ Verified valid status transitions continue to resolve the correct audit action.
  • ✅ Confirmed the new typed exception is thrown when a transition lacks a corresponding audit action.
  • ✅ Verified route-level error handling correctly distinguishes the new exception from unexpected internal errors.
  • ✅ Ensured existing verifier status transition tests continue to pass.
  • ✅ Executed npm test successfully with project coverage meeting the required threshold.

Benefits

  • Eliminates reliance on a generic Error for a known application failure mode.
  • Makes audit action mapping inconsistencies easier to identify and debug.
  • Enables callers and middleware to catch and handle the failure explicitly.
  • Improves observability by grouping these failures under a dedicated exception type instead of generic internal server errors.
  • Maintains consistency with the project's existing typed exception pattern.

Documentation

  • Documented the new exception and the conditions under which it is raised.
  • Added notes describing the relationship between status transition validation and audit action lookup.
  • Updated error-handling documentation where applicable.

Checklist

  • Dedicated typed exception added
  • Generic Error replaced
  • Route error handling updated where necessary
  • Tests added and passing
  • Documentation updated
  • Ready for review

closes #1286

…tusAction gap (Disciplr-Org#1286)

Add MissingVerifierAuditActionError typed exception class (mirroring InvalidVerifierStatusTransitionError) so statusAction-driven audit lookup failures produce a catchable, distinguishable error instead of a generic Error. Catch it in PATCH /:userId, transitionStatus helper, and reinstate handler to return 500 with the specific error message.
@drips-wave

drips-wave Bot commented Jul 31, 2026

Copy link
Copy Markdown

@Ayomide-codex Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

getChangedFields-driven audit action lookup throws a generic Error instead of a typed, catchable exception

1 participant