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

feature request: add error return value to Translate() #151

Open
mildwonkey opened this issue May 16, 2023 · 4 comments
Open

feature request: add error return value to Translate() #151

mildwonkey opened this issue May 16, 2023 · 4 comments
Labels
prio/mid Medium priority readiness/minimum Requisite for achieving a minimum readiness

Comments

@mildwonkey
Copy link

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.

func (i *Instance) Translate(to SyntacticVersion) (*Instance, TranslationLacunas) {

@joanlopez
Copy link
Contributor

Could you provide any specific example to reproduce this issue, please? 🙏🏻

@mildwonkey
Copy link
Author

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

@mildwonkey
Copy link
Author

mildwonkey commented May 22, 2023

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 #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)

@sdboyer
Copy link
Contributor

sdboyer commented May 23, 2023

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):

  • In lenses, there must exist exactly one lens for each expected pair of version numbers
  • In each lens result, there must exist at least one "assignment" for every field in the to schema? (handwave handwave optional fields)

@joanlopez joanlopez added prio/mid Medium priority readiness/minimum Requisite for achieving a minimum readiness labels Jun 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prio/mid Medium priority readiness/minimum Requisite for achieving a minimum readiness
Projects
None yet
Development

No branches or pull requests

3 participants