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: get a diff only when in debug #55

Merged
merged 5 commits into from
Mar 30, 2023
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
2 changes: 1 addition & 1 deletion proto/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func mergedFileDescriptors(debug bool) (*descriptorpb.FileDescriptorSet, error)
// If there's a mismatch, we log a warning. If there was no
// mismatch, then we do nothing, and take the protoregistry file
// descriptor as the correct one.
if !protov2.Equal(protodesc.ToFileDescriptorProto(protoregFd), fd) {
if !protov2.Equal(protodesc.ToFileDescriptorProto(protoregFd), fd) && debug {
Copy link
Member

@julienrbrt julienrbrt Mar 30, 2023

Choose a reason for hiding this comment

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

Oh, I understand now what you meant on Slack. The diff isn't printed anyway, because it is printed only on debug... So even before that we did not have a way to easily call debug from the SDK.

Maybe in a follow-up we should add an option in proto.MergedRegistry() to call DebugFileDescriptorsMismatch instead of MergedFileDescriptors? This way we can handle the display of the debug directly in the SDK.

julienrbrt marked this conversation as resolved.
Show resolved Hide resolved
diff := cmp.Diff(protodesc.ToFileDescriptorProto(protoregFd), fd, protocmp.Transform())
diffErr = append(diffErr, fmt.Sprintf("Mismatch in %s:\n%s", *fd.Name, diff))
}
Expand Down