avoiding #732 by checking for empty versions list for recipe sync #738
3 Participants
Notifications
Total Time Spent: 1 hour 23 minutes
Due Date
ammaratef45
1 hour 23 minutes
No due date set.
Dependencies
No dependencies set.
Reference: toolshed/abra#738
Reference in New Issue
Block a user
No description provided.
Delete Branch "732"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
as title says (and with unit tests ;))
I no longer have a reproduction case for #732 to see if this fixes it unfortunately, but it looks like it would.
Thank you so much @ammaratef45! I've tried to send some breadcrumbs about what I think might be the issue, similarly to #706. I think we're getting closer to the culprit on this one but not quite there... see what you think about i!
@ -299,2 +294,4 @@)}func getLatestVersion(recipe recipePkg.Recipe, catl recipePkg.RecipeCatalogue) string {If you
log.Fatal(err)in a function, you should (in the world of Golang) be sending back that error.log.Fatalgets hard to track when you call a function in a function in a function etc. So, I would do here(string, error)and instead oflog.Fatal(err)I would doreturn "", err. In some cases, you can evenreturn "", fmt.Errorf(i18n.G("my cool translated explanation of the error with additional context: %s", err)). See other error handling elsewhere for more context. In general, we need to thread all errors back to the CLI main command function and only there will thelog.Fatalhappen. This is at least, the idea.@ -301,0 +299,4 @@if err != nil {log.Fatal(err)}latestRecipeVersion := "0.0.0"Hey, I think #706 (comment) still applies, nowhere else in the history of the recipe config commons have we ever used
0.0.0(?) and I fear this might break something else.Isn't it enough to do the
len(versions) > 0 { ...}to avoid theindex out of rangeand return an empty list therefore providing there are no recipe versions for this recipe?I think the problem goes a bit deeper however because the logic block before should catch the lack of recipe versions and prompt the user to choose an initial version? So, something is failing in the
if len(tags) == 0 && nextTag == "" {below?This is a pretty drive-by review but I think the bug is that
nextTaggets handled (the maintainer chooses an initial version) but then the code assumestags(existing recipe versions) has some entries in it? I hope this is making sense....@decentral1se Hmmm, it seems like
if len(tags) == 0 && nextTag == ""isn't working because of the presence of local tags that are not in the catalogue (therefore versions is still an empty list), I wonder if we are fixing more than 1 bug here, will reproduce on a new test recipe and see!P.S. "0.0.0" wasn't a problem because it was never used, it just provided a placeholder value to avoid indexing an empty list, bad readability though, should probably just return an error and handle that error properly from the caller
Nope, I tried on a new recipe and the error didn't happen, unless @jade you can confirm either the state of your local setup when you encountered the error (did you have local tags?) or provide your abra version to match the error line number to make sure the error is the same as the case I found with shlink
The error message on
abra version 0.11.0-beta-1c4abcfis identical on my end (copied below) and lines refer to versions not tags having an empty list when it was being accessedside note, how come the error messages include paths from your machine/user @decentral1se? is it because you build the binaries? 😆
@decentral1se Okay I'm now fairly confident we have the right issue at hand (pending confirmation from @jade on either points asked above), I've addressed your other questions regarding the errors and removed the "0.0.0" part (replaced with an empty string and an error that the caller ignores/tolerates) to avoid confusion.
avoiding #732 by checking for empty versions list for recipe syncto WIP: avoiding #732 by checking for empty versions list for recipe syncWIP: avoiding #732 by checking for empty versions list for recipe syncto avoiding #732 by checking for empty versions list for recipe syncLGTM 💟