Error thrown before the start_time causes delta for end_time to fail
scott-wyatt opened this issue · 1 comments
scott-wyatt commented
Error
1) test register user should fail when email address already taken and return error (Conduit.UsersTest)
test/conduit/users/users_test.exs:69
** (FunctionClauseError) no function clause matching in Commanded.Middleware.Auditing.delta/1
The following arguments were given to Commanded.Middleware.Auditing.delta/1:
%Commanded.Middleware.Pipeline{assigns: %{error: :validation_failure, error_reason: %{email: ["has already been taken"]}},
...
To Reproduce
Add commanded-audit-middleware to Conduit, and then run mix test
.
Suggested Solution
Pattern Matching for delta
for when a delta does not yet have a start_time and error is already thrown.
slashdotdash commented
The auditing middleware needs to be the first middleware defined in your router to ensure it gets executed before any other middleware can halt command dispatch.
Probably worth doing either or both of the following:
- add a note to the README to explain that audit middleware must be defined in a router first (before any halting middleware).
- add a check to the
success/1
andfailure/1
fuctions to ensure the audit middleware has been initialised (and log an error to warn users to define auditing middleware first)
Happy to accept a PR to help fix the issue.