rackerlabs/api-checker — pull request #206 by RackerWilliams (2014-05-06 15:19:35+00:00)
Title: Use longest path from start when deciding what error message to display

Currently, multiple validation rules fail, it returns the error associated with the validation whose path from the start state is longest. For example, suppose we have two paths that fail assertions.

s->a->b->(c)->d->f

and

s->a->(e)

We’d return error associated with state c, because that’s furthest from the start state s. We wouldn’t return e because that’s simply one step away from s. The way we compute the length from s is by computing the shortest path for each state from s.

The case you’re running into looks something like this

s->a->b->(c)->d->-f

and

s->g->(f)

In this case the states in error are (c) and (f), but notice that state f is in both paths. We are returning error c. This is because the shortest path to c from s is 3 steps, and the shortest path to f is 2 steps. The correct error message is actually f. We should be comparing based on longest path for f, instead of shortest path.