-
Notifications
You must be signed in to change notification settings - Fork 277
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
Surface module description in command outputs and errors when possible #3271
Conversation
error handling for cmds that expect uniq module paths; add todo test workspace test add comments update comments update comment rearrange cleanup update comment
author Oliver Sun <[email protected]> 1723165177 -0400 committer Oliver Sun <[email protected]> 1724277829 -0400 parent 06e3428 author Oliver Sun <[email protected]> 1723165177 -0400 committer Oliver Sun <[email protected]> 1724277651 -0400 add includes update tests build all modules underneath the input directory add newline fix lint update test add comments fix comment comment update comment fix write buf yaml file changelog only allow either includes or excludes update error message handle possible duplicate paths improve bucketID format update errors remove todo comment fix verb and add test update --exclude-path to allow pointing at a module clear module targets paths if module is excluded;add some test files update comment revert decision that allowed --exclude-path to point at module roots post merge new line update comment update update comment add comment comment rename update comment remove unused test files
The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).
|
@@ -1023,6 +1023,7 @@ func (c *controller) buildTargetImageWithConfigs( | |||
c.logger.Debug( | |||
"building image for target module", | |||
zap.String("moduleOpaqueID", module.OpaqueID()), | |||
zap.String("moduleDescription", module.Description()), |
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.
New:
buf lint foo --debug
...
DEBUG building image for target module {"moduleOpaqueID": "foo-00001", "moduleDescription": "path: \"foo\", excludes: \"foo/bar\""}
...
We could also just get rid of the opaque ID here, but keeping it for debugging purpose.
_, _ = builder.WriteString(opaqueID) | ||
if i != len(m.OpaqueIDs)-1 { | ||
_, _ = builder.WriteString(` -> `) | ||
_, _ = builder.WriteString("cycle detected in module dependencies:\n") |
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.
New:
buf dep graph
Failure: cycle detected in module dependencies:
path: "foo", excludes: "foo/bar"
-> path: "foo", includes: "foo/bar/baz"
-> path: "foo", includes: "foo/bar", excludes: "foo/bar/baz"
-> path: "foo", excludes: "foo/bar"
@@ -449,7 +457,7 @@ func getV1Beta1ProtoUploadRequestContent( | |||
return nil, syserror.New("expected local Module in getProtoLegacyFederationUploadRequestContent") | |||
} | |||
if module.ModuleFullName() == nil { | |||
return nil, syserror.Newf("expected module name for local module %q", module.OpaqueID()) | |||
return nil, syserror.Newf("expected module name for local module %q", module.Description()) |
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.
Description vs opaqueID does not really matter for syserrors, but I changed it just in case.
@@ -125,7 +125,7 @@ func getSingleRegistryForContentModules(contentModules []bufmodule.Module) (stri | |||
for _, module := range contentModules { | |||
moduleFullName := module.ModuleFullName() | |||
if moduleFullName == nil { | |||
return "", syserror.Newf("expected module name for %q", module.OpaqueID()) | |||
return "", syserror.Newf("expected module name for %q", module.Description()) |
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.
Description vs opaqueID does not really matter for syserrors, but I changed it just in case.
@@ -143,5 +143,5 @@ func moduleToString(module bufmodule.Module) string { | |||
} | |||
return moduleFullName.String() | |||
} | |||
return module.OpaqueID() | |||
return module.Description() |
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.
New:
buf dep graph
digraph {
"buf.build/osun/separate" -> "path: "foo", excludes: "foo/bar""
"path: "foo", excludes: "foo/bar"" -> "path: "foo", includes: "foo/bar/baz""
"path: "foo", includes: "foo/bar/baz"" -> "path: "foo", includes: "foo/bar", excludes: "foo/bar/baz""
}
This output is escaped. Perhaps we should update the definition of Module.Description
not to quote paths.
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 is a breaking change and isn't desirable - definitely revert 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.
Reverted in 9f854e6
moduleConfig, | ||
) | ||
if _, ok := seenModuleDescriptions[moduleDescription]; ok { | ||
return nil, fmt.Errorf("multiple module configs found with the same description: %q", moduleDescription) |
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.
New
buf build
Failure: multiple module configs found with the same description: "path: \"foo\", excludes: \"foo/bar\""
The \"
looks a bit awkward, should we update the definition of Module.Description not to quote paths?
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.
%s yes
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.
Double checking, we want
Failure: ... the same description: "path: foo, excludes: foo/bar"
instead of
Failure: ... the same description: path: "foo", excludes: "foo/bar"
right?
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.
the latter, which should come through if you use %s instead of %q
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.
Updated in b4bc182
slicesext.Map(allDepModuleDescriptions, func(moduleDescription string) string { return " " + moduleDescription }), | ||
"\n", | ||
), | ||
) |
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.
Failure: all dependencies for module "buf.build/osun/separate" must be named but these modules are not:
path: "foo", excludes: "foo/bar"
path: "foo", includes: "foo/bar", excludes: "foo/bar/baz"
path: "foo", includes: "foo/bar/baz"
// - proot/foo | ||
// - path: proto | ||
// excludes: | ||
// - proot/foo |
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.
Should this check happen during bufYAMLFile
parsing instead?
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.
I think it's fine for this to happen in this layer, since WorkspaceProvider
encapsulates the process of parsing the buf.yaml
. I think this logic is pretty straightforward here.
// - proot/foo | ||
// - path: proto | ||
// excludes: | ||
// - proot/foo |
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.
I think it's fine for this to happen in this layer, since WorkspaceProvider
encapsulates the process of parsing the buf.yaml
. I think this logic is pretty straightforward here.
This PR makes
module.Description
public to surface module description in command outputs and errors when possible.This PR also adds a check for module description uniqueness in workspace provider, before passing them to the module set builder. This means we correctly return an user error when it's an user error, i.e. the buf.yaml v2 is not well formed.