Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error thrown before the start_time causes delta for end_time to fail #4

Open
scott-wyatt opened this issue Dec 1, 2018 · 1 comment

Comments

@scott-wyatt
Copy link

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
Copy link
Member

slashdotdash commented Dec 2, 2018

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 and failure/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.

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

No branches or pull requests

2 participants