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

Option to consistently sort tags #51

Closed
jgkawell opened this issue Jun 17, 2024 · 10 comments
Closed

Option to consistently sort tags #51

jgkawell opened this issue Jun 17, 2024 · 10 comments
Assignees

Comments

@jgkawell
Copy link

Often I run into the case mentioned in #38 where I will regenerated a file and end up with changes because the sorting of the tags changes randomly on each compilation. This causes issues in automation because changes are being detected in generated files when no functional change has actually been made. Here's an example of the git diff:

image

I'm seeing this issue on the latest stable version v1.0.1.

@jgkawell
Copy link
Author

Not really sure if this is a bug or a feature request. I'm happy to implement this if there's interest and you can point me in the right direction.

@ucpr
Copy link
Collaborator

ucpr commented Jul 8, 2024

Hi @jgkawell,

Thank you for the report. I'll take a look at it shortly.

How often does this problem occur?

@jgkawell
Copy link
Author

@ucpr Sorry for the late reply. This happens every time I generate files using the plugin. For example, I might generate the files once and get one ordering of tags and then generate the files immediately after and get a different ordering. The order seems to be completely random.

@ucpr
Copy link
Collaborator

ucpr commented Jul 23, 2024

@jgkawell

I attempted to reproduce the problem in my environment, but I was unable to do so. To help me investigate further, could you please provide the minimal configuration required to reproduce the issue?

@joaopedrovbs
Copy link

I also have the same problem! It always changes the order for the auto-generated tags. This is what I have in the buf.gen.tag.yaml :

version: v1
plugins:
  - plugin: gotag
    out: .
    opt: paths=source_relative,outdir=gen/go,auto=json-as-lower_camel_case+bson-as-lower_camel_case+db-as-snake_case

@jgkawell
Copy link
Author

Okay I've got a repeatable example for you:

  • buf version = 1.35.1
  • protoc-gen-go version = 1.34.2
  • protoc-gen-gotag version = 1.0.1

buf.yaml

version: v1

buf.gen.go.yaml

version: v1
plugins:
  - name: go
    out: .
    opt:
      - paths=source_relative

buf.gen.gotag.yaml

version: v1
plugins:
  - name: gotag
    out: .
    opt:
      - outdir=.
      - paths=source_relative
      - xxx=pg+"-" bun+"-" json+"-" yaml+"-" csv+"-"
      - auto=pg-as-lower_snake+bun-as-lower_snake+yaml-as-lower_snake+csv-as-lower_snake+json-as-lower_snake

service.proto

syntax = "proto3";

package v1;

option go_package = "github.com/example/example";

service EchoService {
    rpc Speak(SpeakRequest) returns(SpeakResponse) {}
}

message SpeakRequest {
    string input = 1;
}

message SpeakResponse {
    string output = 2;
}

Running the below command over and over will randomly change the position of the tags:

buf generate --template buf.gen.go.yaml && buf generate --template buf.gen.gotag.yaml

@ucpr
Copy link
Collaborator

ucpr commented Jul 30, 2024

Thank you!
I was able to reproduce the issue and will work on it this weekend.

@ucpr ucpr self-assigned this Aug 4, 2024
@ucpr
Copy link
Collaborator

ucpr commented Aug 10, 2024

Hi @jgkawell @joaopedrovbs,

Thank you for your support in investigating the issue.
We have just released the fixed version.

Please try it out:
https://github.com/srikrsna/protoc-gen-gotag/releases/tag/v1.0.2

@ucpr
Copy link
Collaborator

ucpr commented Aug 10, 2024

I will be closing the issue. If you encounter any problems, feel free to reach out.

@ucpr ucpr closed this as completed Aug 10, 2024
jgkawell added a commit to steady-bytes/draft that referenced this issue Aug 10, 2024
Upgrading `protoc-gen-gotag` to resolve random ordered tags:
srikrsna/protoc-gen-gotag#51

Also fixed the npm imports for buf/connectrpc
@jgkawell
Copy link
Author

@ucpr This is working great! Thank you for the fix!

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