operator-framework / deppy

Deppy: The dependency resolver for Kubernetes
Apache License 2.0
14 stars 21 forks source link

Using `solver.Solution.Error()` is awkward and unintuitive #139

Closed joelanford closed 9 months ago

joelanford commented 9 months ago

I expected this to work correctly:

if err := solution.Error(); err != nil {
  log.Println(err)
}

In reality, this code always logs "constraints not satisfiable", even the the solution was SAT.

To handle this correctly, I had to use this code instead:

unsat := deppy.NotSatisfiable{}
if errors.As(solution.Error(), &unsat); len(unsat) > 0 {
    log.Println(unsat.Error())
}

We should fix solution.Error() to return an untyped nil error if the solution was SAT.