check_handlers/1 crashes with undef when a handler's command module is missing #6

Open
opened 2026-12-01 04:41:24 +00:00 by mercurius · 0 comments
Member

Purpose (fix): evoq_command_handler:check_handlers/1 names a handler whose command module is missing, instead of crashing with undef.

Refs reckon-db-org/evoq#3

The defect

check_handlers/1 (forge PR 5) loads each handler and reads its behaviour attributes. It then calls (Handler:command_module()):command_type(). When that command module cannot be loaded (renamed, deleted, mistyped), the call raises undef and does not return a named problem. A service's test still fails, but on a crash that names nothing, where {not_loadable, ...} or {wrong_command_type, ...} would name the desk.

Found by Uranus in the review of PR 5 (a note, not a FAIL).

Fix shape

Check the command module like the handler: code:ensure_loaded/1 first. If it fails, answer {command_module_not_loadable, CommandType, Handler, CommandModule, Reason} and add it to handler_problem(). Add one test for it, and a mutant on the new clause.

Done when

  • a handler whose command_module/0 names an unloadable module makes check_handlers/1 return {error, [{command_module_not_loadable, ...}]}, with no crash
Purpose (fix): `evoq_command_handler:check_handlers/1` names a handler whose command module is missing, instead of crashing with `undef`. Refs reckon-db-org/evoq#3 ## The defect `check_handlers/1` (forge PR 5) loads each handler and reads its behaviour attributes. It then calls `(Handler:command_module()):command_type()`. When that command module cannot be loaded (renamed, deleted, mistyped), the call raises `undef` and does not return a named problem. A service's test still fails, but on a crash that names nothing, where `{not_loadable, ...}` or `{wrong_command_type, ...}` would name the desk. Found by Uranus in the review of PR 5 (a note, not a FAIL). ## Fix shape Check the command module like the handler: `code:ensure_loaded/1` first. If it fails, answer `{command_module_not_loadable, CommandType, Handler, CommandModule, Reason}` and add it to `handler_problem()`. Add one test for it, and a mutant on the new clause. ## Done when - [ ] a handler whose `command_module/0` names an unloadable module makes `check_handlers/1` return `{error, [{command_module_not_loadable, ...}]}`, with no crash
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
reckon-db-org/evoq#6
No description provided.