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

RSDK-9721: Improve firstRun error message for missing meta.json. #4726

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dgottlieb
Copy link
Member

No description provided.

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Jan 17, 2025
//
// .viam/packages/data/module/e76d1b3b-0468-4efd-bb7f-fb1d2b352fcb-viamrtsp-0_1_0-linux-amd64/
// .viam/packages/data/module/e76d1b3b-0468-4efd-bb7f-fb1d2b352fcb-viamrtsp-0_1_0-linux-amd64/bin/
// .viam/packages/data/module/e76d1b3b-0468-4efd-bb7f-fb1d2b352fcb-viamrtsp-0_1_0-linux-amd64/bin.first_run_succeeded
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this was intentional. Or maybe it was. But it's certainly a bit odd to concatenate a "directory" with a "file suffix" without some "file prefix".

I started to "fix" this by using filepath.Join. And additionally being "backwards compatible" by checking for both bin.first_run_succeeded as well as bin/.first_run_succeeded.

In the end I figured it's not worth risking breaking this code for aesthetics. But found it useful to document a concrete example such that readers aren't left wondering if something is wrong.

@@ -272,7 +276,7 @@ func (m *Module) FirstRun(
var pathErr *os.PathError
switch {
case errors.As(err, &pathErr):
logger.Debugw("meta.json not found, skipping first run", "error", err)
logger.Infow("meta.json does not exist, skipping first run")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I waffled on whether this case should also be writing out a "first run succeeded" file. I opted not to -- just in case we ever had a bug with getJSONManifest incorrectly missing a file that it should be seeing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was wrapping errors how we failed this check?

@@ -15,7 +15,6 @@ import (
"sync"
"time"

"github.com/pkg/errors"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stacks are coming from my favorite library. I haven't 100% verified I used the corollary methods in "stderrors" properly. Particularly the Join/As/Is. I'm leaning on unit tests making the appropriate assertions.

"reflect"
"regexp"
"strings"

"github.com/pkg/errors"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My "find definition" jumping while looking at module.go brought me here

@dgottlieb dgottlieb requested a review from cheukt January 17, 2025 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants