-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix config add-dir regression #406
Conversation
@colin-axner , we are actually getting nil pointer dereference issue from here. Since key is not added for chain, we are unable to get address of it and that's the reason, we are getting error. But we need chain to validate provided identifiers. Can you suggest any solution for this? |
@akhilkumarpilli interesting. I would have thought the key is being set when the chain is being set (which I assumed occurs in the for loop over files). I will take a closer look in a second. Ideally we set the chains first then the paths. In this fix though I was hoping to set both the chains and the paths and then do validation. |
@akhilkumarpilli are you still getting the error? I tried reproducing @michaelfig's error (thanks for the how-to-reproduce steps) and everything works for me |
cmd/config.go
Outdated
@@ -263,6 +259,12 @@ func cfgFilesAdd(dir string) (cfg *Config, err error) { | |||
} | |||
fmt.Printf("added chain %s...\n", c.ChainID) | |||
} | |||
for _, p := range cfg.Paths { | |||
if err = config.ValidatePath(p); err != nil { | |||
fmt.Println("Error occured...Config is not updated") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Println("Error occured...Config is not updated") |
maybe we could wrap the error and say the path validation failed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah Sure, but we are displaying added chain logs before. That's the reason, I wrote Config is not updated
I am still getting issue. Can you try once by clearing config? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you update, Skipping non chain file...
to say added path: %s\n", pathName
are you getting this?
|
I am getting this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix. I'd suggest to return the errors when encountered
cmd/config.go
Outdated
fmt.Printf("%s: %s\n", pth, err.Error()) | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should return the error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will update
cmd/config.go
Outdated
fmt.Printf("failed to read file %s, skipping...\n", pth) | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
cmd/config.go
Outdated
fmt.Printf("failed to unmarshal file %s, skipping...\n", pth) | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
cmd/config.go
Outdated
fmt.Printf("%s: failed to validate path: %s\n", pth, err.Error()) | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
cmd/config.go
Outdated
fmt.Printf("%s: %s\n", pth, err.Error()) | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Fixes: #401
Splits the
add-dir
comman intoadd-chains
andadd-paths
. Adding chain configuration files and adding a key is required before runningadd-paths
since add-paths will query the chains to ensure the path is valid