Open mildwonkey opened 1 year ago
Could you provide any specific example to reproduce this issue, please? 🙏🏻
I CAN NOW! https://github.com/mildwonkey/thema-examples/tree/main/translate
There's a repo full repo in there, but it's as simple as calling Translate on a schema version that doesn't exist
Another case when Translate() panics is if there are no lenses defined:
panic: #Translate.out.steps._accum.1._lens: index out of range [0] with length 0:
/github.com/grafana/thema/translate.cue:104:31
That specific issue is similar to what I referenced https://github.com/grafana/thema/issues/152 (though when I opened that issue I wasn't getting a panic, just silent failure - I'm not sure what was different but I'll include a repro if it comes up again)
if there are no lenses defined:
yup, it's another invariant that needs checking. "Lens completeness" is its whole own invariant area. I'm guessing we'll be able to write checkers in stages. From where we are now, the following two checks are clearly necessary (but not sufficient):
lenses
, there must exist exactly one lens for each expected pair of version numbersresult
, there must exist at least one "assignment" for every field in the to
schema? (handwave handwave optional fields)
Translate()
does not currently return an error, but there are cases in which it may panic, so we should return an error when issues are encountered.https://github.com/grafana/thema/blob/e1d0481fa785f07a2aadac64d848e11abe5e83b6/instance.go#L152