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

panic in generate #21

Closed
iamnoah opened this issue Aug 7, 2024 · 3 comments
Closed

panic in generate #21

iamnoah opened this issue Aug 7, 2024 · 3 comments

Comments

@iamnoah
Copy link

iamnoah commented Aug 7, 2024

This proto:

syntax = "proto3";
package foo;
option go_package = "foo/bar";

import "google/api/annotations.proto";
import "buf/validate/validate.proto";


message Rew {
  string t = 1 [(buf.validate.field).required = true];
}

message Res {
}

service Foo {
  rpc Status(Rew) returns (Res) {
    option (google.api.http) = {
      get: "/a"
    };
  }
}

buf.yaml

version: v2
modules:
  - path: proto
deps:
  - buf.build/googleapis/googleapis
  - buf.build/grpc-ecosystem/grpc-gateway
  - buf.build/bufbuild/protovalidate
lint:
  use:
    - FIELD_NO_DESCRIPTOR
  except:
    - ENUM_FIRST_VALUE_ZERO
    - FIELD_NOT_REQUIRED
    - IMPORT_USED
    - PACKAGE_NO_IMPORT_CYCLE
    - PROTOVALIDATE
    - SYNTAX_SPECIFIED
  disallow_comment_ignores: true
breaking:
  except:
    - EXTENSION_NO_DELETE
    - FIELD_SAME_DEFAULT

buf.gen.yaml:

version: v2
plugins:
  - local: protoc-gen-connect-openapi
    out: gen/OpenAPI

v0.8.6 in the path:

buf generate

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x1c8 pc=0x1032b4378]

goroutine 1 [running]:
github.com/sudorandom/protoc-gen-connect-openapi/internal/converter/protovalidate.SchemaWithFieldAnnotations(0x14000252788, {0x1035ad328, 0x140003e7600})
        /Users/noah/go/pkg/mod/github.com/sudorandom/protoc-gen-connect-openapi@v0.8.6/internal/converter/protovalidate/schema.go:34 +0xa8
github.com/sudorandom/protoc-gen-connect-openapi/internal/converter/util.ScalarFieldToSchema(0x0, {0x1035ad328, 0x140003e7600})
        /Users/noah/go/pkg/mod/github.com/sudorandom/protoc-gen-connect-openapi@v0.8.6/internal/converter/util/schema.go:120 +0x674
github.com/sudorandom/protoc-gen-connect-openapi/internal/converter/util.FieldToSchema(0x0, {0x1035ad328, 0x140003e7600})
        /Users/noah/go/pkg/mod/github.com/sudorandom/protoc-gen-connect-openapi@v0.8.6/internal/converter/util/schema.go:81 +0x4a4
github.com/sudorandom/protoc-gen-connect-openapi/internal/converter/googleapi.httpRuleToPathMap({{0x0, 0x0}, {0x1033014f3, 0x4}, {0x0, 0x0}, 0x0, 0x0, 0x14000104bd0, 0x0, ...}, ...)
        /Users/noah/go/pkg/mod/github.com/sudorandom/protoc-gen-connect-openapi@v0.8.6/internal/converter/googleapi/paths.go:87 +0x9d8
github.com/sudorandom/protoc-gen-connect-openapi/internal/converter/googleapi.MakePathItems({{0x0, 0x0}, {0x1033014f3, 0x4}, {0x0, 0x0}, 0x0, 0x0, 0x14000104bd0, 0x0, ...}, ...)
        /Users/noah/go/pkg/mod/github.com/sudorandom/protoc-gen-connect-openapi@v0.8.6/internal/converter/googleapi/paths.go:28 +0xe4
github.com/sudorandom/protoc-gen-connect-openapi/internal/converter.fileToPathItems({{0x0, 0x0}, {0x1033014f3, 0x4}, {0x0, 0x0}, 0x0, 0x0, 0x14000104bd0, 0x0, ...}, ...)
        /Users/noah/go/pkg/mod/github.com/sudorandom/protoc-gen-connect-openapi@v0.8.6/internal/converter/paths.go:24 +0x1f0
github.com/sudorandom/protoc-gen-connect-openapi/internal/converter.appendToSpec({{0x0, 0x0}, {0x1033014f3, 0x4}, {0x0, 0x0}, 0x0, 0x0, 0x14000104bd0, 0x0, ...}, ...)
        /Users/noah/go/pkg/mod/github.com/sudorandom/protoc-gen-connect-openapi@v0.8.6/internal/converter/converter.go:282 +0xb08
github.com/sudorandom/protoc-gen-connect-openapi/internal/converter.Convert(0x1400019b080)
        /Users/noah/go/pkg/mod/github.com/sudorandom/protoc-gen-connect-openapi@v0.8.6/internal/converter/converter.go:197 +0x93c
github.com/sudorandom/protoc-gen-connect-openapi/internal/converter.ConvertFrom({0x103595358?, 0x140000a0048?})
        /Users/noah/go/pkg/mod/github.com/sudorandom/protoc-gen-connect-openapi@v0.8.6/internal/converter/converter.go:108 +0xfc
main.main()
        /Users/noah/go/pkg/mod/github.com/sudorandom/protoc-gen-connect-openapi@v0.8.6/main.go:15 +0x30
Failure: plugin protoc-gen-connect-openapi: exit status 2

Doesn't trigger without required = true, and other random edits seem to sometimes get through... removing the option (google.api.http) keeps it from triggering consistently.

@sudorandom
Copy link
Owner

Thanks so much. I can probably get this fixed quickly. Thank you SO MUCH for the minimal reproduction steps. That helps so much.

@sudorandom
Copy link
Owner

@iamnoah this should be fixed now. I released a patch including this fix as v0.8.7.

@iamnoah
Copy link
Author

iamnoah commented Aug 7, 2024

@sudorandom thanks, it works!

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

2 participants