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

Fix InvalidRemoteErr panic #2728

Merged
merged 4 commits into from
Jan 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions private/buf/cmd/buf/command/mod/modupdate/modupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,13 @@ func getDependencies(
if len(moduleConfig.Build.DependencyModuleReferences) == 0 {
return nil, nil
}
var remote string
var (
remote string
moduleIdentity string
emcfarlane marked this conversation as resolved.
Show resolved Hide resolved
)
if moduleConfig.ModuleIdentity != nil && moduleConfig.ModuleIdentity.Remote() != "" {
remote = moduleConfig.ModuleIdentity.Remote()
moduleIdentity = moduleConfig.ModuleIdentity.IdentityString()
} else {
// At this point we know there's at least one dependency. If it's an unnamed module, select
// the right remote from the list of dependencies.
Expand All @@ -226,10 +230,11 @@ func getDependencies(
return nil, fmt.Errorf(`File %q has invalid "deps" references`, existingConfigFilePath)
}
remote = selectedRef.Remote()
moduleIdentity = selectedRef.IdentityString()
container.Logger().Debug(fmt.Sprintf(
`File %q does not specify the "name" field. Based on the dependency %q, it appears that you are using a BSR instance at %q. Did you mean to specify "name: %s/..." within %q?`,
existingConfigFilePath,
selectedRef.IdentityString(),
moduleIdentity,
remote,
remote,
existingConfigFilePath,
Expand Down Expand Up @@ -269,7 +274,7 @@ func getDependencies(
)
if err != nil {
if remote != bufconnect.DefaultRemote {
return nil, bufcli.NewInvalidRemoteError(err, remote, moduleConfig.ModuleIdentity.IdentityString())
return nil, bufcli.NewInvalidRemoteError(err, remote, moduleIdentity)
emcfarlane marked this conversation as resolved.
Show resolved Hide resolved
}
return nil, err
}
Expand Down
Loading