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

False positive: Moving a type to another file while public importing is not incompatible? #2981

Closed
JanecekPetr opened this issue May 15, 2024 · 2 comments

Comments

@JanecekPetr
Copy link

Before (syntax and package declarations omitted):

  • common.proto:

    // empty
    
  • specific.proto:

    import "common.proto";
    
    enum BlaBlaType {
      BLA_BLA_TYPE_UNSPECIFIED = 0;
      BLA_BLA_TYPE_NONE = 1;
      BLA_BLA_TYPE_OF = 2;
      BLA_BLA_TYPE_YOUR = 3;
      BLA_BLA_TYPE_BUSINESS = 4;
    }

After:

  • common.proto:

    enum BlaBlaType {
      BLA_BLA_TYPE_UNSPECIFIED = 0;
      BLA_BLA_TYPE_NONE = 1;
      BLA_BLA_TYPE_OF = 2;
      BLA_BLA_TYPE_YOUR = 3;
      BLA_BLA_TYPE_BUSINESS = 4;
    }
  • specific.proto:

    import public "common.proto";
    
    // + some message using the enum

We got

Previously present enum "BlaBlaType" was deleted from file.

This seems unnecessary as the resulting effective set of available types is the same, or are we missing something?

@nicksnyder
Copy link
Member

Moving this issue to bufbuild/buf since the behavior in question is implemented by the Buf CLI. The GitHub action just invokes the Buf CLI.

@nicksnyder nicksnyder transferred this issue from bufbuild/buf-breaking-action May 15, 2024
@bufdev
Copy link
Member

bufdev commented May 16, 2024

The FILE breaking change level prevents moving across files, which deals with languages where types are imported on a per-file basis. For example, in C++, if your source code imports "specific.pb.h", moving the enum to common.proto means that the type will now be in "common.pb.h", potentially resulting in compile errors for source code that doesn't import "common.pb.h". Some languages may have their header files themselves import "common.pb.h", but the FILE level aims to be as strict as possible, as we can't assume how individual language generators work. You may want to reduce your breaking change category to PACKAGE, see https://buf.build/docs/breaking/rules#categories for more details.

@bufdev bufdev closed this as completed May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants