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

Workflow schema validation errors should include more information #267

Closed
carolyncole opened this issue Jan 13, 2017 · 3 comments · Fixed by #4028
Closed

Workflow schema validation errors should include more information #267

carolyncole opened this issue Jan 13, 2017 · 3 comments · Fixed by #4028

Comments

@carolyncole
Copy link
Contributor

Descriptive summary

I got the following information from loading workflows in the spec internal in hyrax:

{:workflows=>{0=>{:actions=>{2=>{:notifications=>{0=>{:name=>["must be an initialized Ruby constant"]}}}}}}}

There are two workflows in the system and I obviously tweaked one of them, but there is no indication of which workflow file failed, what the workflow name, action name, notification name, or the value of the item that does not match the validation.

I'm sure I tweaked the workflow by accident, but which one and exactly where is not easy to discern from the error that was produced.

@carolyncole
Copy link
Contributor Author

carolyncole commented Jan 13, 2017

So as it turned out the class name changed for the notification, so I did not change anything, but the class that used to exists no longer exists, so my workflow was now invalid. I figured that out by diffing the template in the code with my template. If I did not have the ability to run a diff I would have NEVER figured this out from the error above. Ok maybe not never but it would have taken me hours....

@jcoyne
Copy link
Member

jcoyne commented Jan 13, 2017

👍 I have had the same problem

@mjgiarlo mjgiarlo added this to the Backlog milestone Jan 14, 2017
@mjgiarlo mjgiarlo changed the title Validation errors should include more information Workflow schema validation errors should include more information Jan 14, 2017
@no-reply no-reply modified the milestones: Backlog, 3.x series Sep 21, 2019
@no-reply
Copy link
Contributor

This still seems high value.

The workflow schema validation output is customizable with https://dry-rb.org/gems/dry-validation/1.0/messages/

They are actually currently pretty informative:

#<Dry::Validation::MessageSet messages=[#<Dry::Schema::Message text="name must be Class" path=[:workflows, 0, :actions, 1, :notifications, 0, :name] predicate=:type? input="FooBar">] options={:source=>[#<Dry::Schema::Message text="must be Class" path=[:workflows, 0, :actions, 1, :notifications, 0, :name] predicate=:type? input="FooBar">], :full=>true}>

but the output is formatted just like that. Much better would be to loop through the messages and output a nicely descriptive error describing the path to the errant key, and the outputting the message text (in this case "name must be a Class") with the actual value.

for example:

"Error on workflow entry [:workflows, 0, :actions, 1, :notifications, 0, :name] name must be Class Got: FooBar"

no-reply pushed a commit that referenced this issue Sep 21, 2019
This is a hack at formatting errors for workflow schema issues.

The new errors are formatted like:

```
Error on workflow entry [:workflows, 0, :label]
      label must be filled
      Got:
Error on workflow entry [:workflows, 0, :description]
      description must be filled
      Got:
Input was:
      {:workflows=>[{:name=>"ulra_submission", :label=>"", :description=>"",
      :actions=>[{:name=>"approve", :from_states=>[{:names=>["under_review"],
      :roles=>["ulra_reviewing"]}], :transition_to=>"reviewed"}]}]}
```

Fixes #267.
no-reply pushed a commit that referenced this issue Sep 21, 2019
This is a hack at formatting errors for workflow schema issues.

The new errors are formatted like:

```
Error on workflow entry [:workflows, 0, :label]
      label must be filled
      Got:
Error on workflow entry [:workflows, 0, :description]
      description must be filled
      Got:
Input was:
      {:workflows=>[{:name=>"ulra_submission", :label=>"", :description=>"",
      :actions=>[{:name=>"approve", :from_states=>[{:names=>["under_review"],
      :roles=>["ulra_reviewing"]}], :transition_to=>"reviewed"}]}]}
```

Fixes #267.
no-reply pushed a commit that referenced this issue Sep 21, 2019
This is a hack at formatting errors for workflow schema issues.

The new errors are formatted like:

```
Error on workflow entry [:workflows, 0, :label]
      label must be filled
      Got:
Error on workflow entry [:workflows, 0, :description]
      description must be filled
      Got:
Input was:
      {:workflows=>[{:name=>"ulra_submission", :label=>"", :description=>"",
      :actions=>[{:name=>"approve", :from_states=>[{:names=>["under_review"],
      :roles=>["ulra_reviewing"]}], :transition_to=>"reviewed"}]}]}
```

Fixes #267.
elrayle pushed a commit that referenced this issue Sep 24, 2019
This is a hack at formatting errors for workflow schema issues.

The new errors are formatted like:

```
Error on workflow entry [:workflows, 0, :label]
      label must be filled
      Got:
Error on workflow entry [:workflows, 0, :description]
      description must be filled
      Got:
Input was:
      {:workflows=>[{:name=>"ulra_submission", :label=>"", :description=>"",
      :actions=>[{:name=>"approve", :from_states=>[{:names=>["under_review"],
      :roles=>["ulra_reviewing"]}], :transition_to=>"reviewed"}]}]}
```

Fixes #267.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants