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

../../pkg/api/v1/account.pb.gw.go:107:3: undefined: runtime.CamelCaseFieldMask #3

Open
sweeny-here opened this issue Jul 28, 2020 · 4 comments
Assignees

Comments

@sweeny-here
Copy link

When building account-service it errors out on:

qwerty@qwerty-mbp > export CGO_ENABLED=0 GOOS=linux GOARCH=amd64 && go build
# optisam-backend/account-service/pkg/api/v1
../../pkg/api/v1/account.pb.gw.go:107:3: undefined: runtime.CamelCaseFieldMask
../../pkg/api/v1/account.pb.gw.go:109:56: not enough arguments in call to runtime.FieldMaskFromRequestBody
	have (io.Reader)
	want (io.Reader, *descriptorpb.DescriptorProto)

The temp fix to comment out lines in file optisam-backend/account-service/pkg/api/v1/account.pb.gw.go

//if protoReq.UpdateMask != nil && len(protoReq.UpdateMask.GetPaths()) > 0 {
//	runtime.CamelCaseFieldMask(protoReq.UpdateMask)
//} else {
//	if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader()); err != nil {
//		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
//	} else {
//		protoReq.UpdateMask = fieldMask
//	}
//}

Can you assist or advise?

sweeny-here pushed a commit to sweeny-here/optisam-backend that referenced this issue Jul 28, 2020
@dharmjit
Copy link

Hi @sweeny-here, this issue comes when there is version mismatch between generators and runtime libraries. We have also faced this earlier. Can you please try building after running below commands

go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u github.com/golang/protobuf/protoc-gen-go

The proper fix is to have tools also versioned under go modules as described
at https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module

Also please note that current optisam version is bit old and we are going to publish the latest version very soon.

@sweeny-here
Copy link
Author

sweeny-here commented Jul 29, 2020

Thanks DHarmjit - I tried your recommendation but it's not playing ball.

Here are the steps I tried based on this article:

The tools.go file was created manually based on the packages declared within the sources:

qwerty@qwerty-mbp > pwd
/Users/qwerty/Hme/Tek/LAC/sam/optisam-backend/

qwerty@qwerty-mbp > cat tools.go 
 // +build tools

 package main

 import  (
 	_ "contrib.go.opencensus.io/exporter/jaeger"
 	_ "contrib.go.opencensus.io/exporter/prometheus"
 	_ "contrib.go.opencensus.io/integrations/ocsql"
 	_ "github.com/InVisionApp/go-health"
 	_ "github.com/InVisionApp/go-logger"
 	_ "github.com/Microsoft/go-winio"
 	_ "github.com/dgraph-io/badger"
 	_ "github.com/dgraph-io/dgo"
 	_ "github.com/dgraph-io/dgraph/gql"
 	_ "github.com/dgraph-io/dgraph/xidmap"
 	_ "github.com/dgrijalva/jwt-go"
 	_ "github.com/docker/distribution"
 	_ "github.com/docker/docker/api/types"
 	_ "github.com/docker/docker/api/types/container"
 	_ "github.com/docker/docker/client"
 	_ "github.com/docker/go-connections"
 	_ "github.com/docker/go-connections/nat"
 	_ "github.com/envoyproxy/protoc-gen-validate"
 	_ "github.com/golang/mock/gomock"
 	_ "github.com/golang/protobuf/proto"
 	_ "github.com/grpc-ecosystem/go-grpc-middleware"
 	_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway"
 	_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"
 	_ "github.com/grpc-ecosystem/grpc-gateway/runtime"
 	_ "github.com/grpc-ecosystem/grpc-gateway/utilities"
 	_ "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap"
 	_ "github.com/grpc-ecosystem/go-grpc-middleware/auth"
 	_ "github.com/grpc-ecosystem/go-grpc-middleware/validator"
 	_ "github.com/grpc-ecosystem/go-grpc-middleware/tags"
 	_ "github.com/julienschmidt/httprouter"
 	_ "github.com/lib/pq"
 	_ "github.com/opencensus-integrations/ocsql"
 	_ "github.com/pkg/errors"
 	_ "github.com/rs/cors"
 	_ "github.com/spf13/afero"
 	_ "github.com/spf13/cobra"
 	_ "github.com/spf13/pflag"
 	_ "github.com/spf13/viper"
 	_ "github.com/stretchr/testify"
 	_ "github.com/vijay1811/pq"
 	_ "go.opencensus.io"
 	_ "go.uber.org/zap"
 	_ "golang.org/x/net/context"
 	_ "golang.org/x/text"
 	_ "golang.org/x/tools/cmd/stringer"
 	_ "google.golang.org/genproto/googleapis/api/annotations"
 	_ "google.golang.org/genproto/googleapis/rpc/code"
 	_ "google.golang.org/genproto/googleapis/rpc/status"
 	_ "google.golang.org/genproto/googleapis/rpc/errdetails"
 	_ "google.golang.org/genproto/protobuf/field_mask"
 	_ "google.golang.org/genproto/protobuf/api"
 	_ "google.golang.org/genproto/protobuf/source_context"
 	_ "google.golang.org/genproto/protobuf/ptype"
 	_ "google.golang.org/grpc"
 	_ "gopkg.in/DATA-DOG/go-sqlmock.v1"
 	_ "gopkg.in/oauth2.v3"
 	_ "gopkg.in/yaml.v2"
 	_ "github.com/golang/protobuf/protoc-gen-go"
 )

Set the module path the root of the optisam-backend repo:

qwerty@qwerty-mbp > export GOBIN=$(pwd)/bin
qwerty@qwerty-mbp > export PATH=$GOBIN:$PATH
qwerty@qwerty-mbp > go env |grep GOMOD
GOMOD="/Users/qwerty/Hme/Tek/LAC/sam/optisam-backend/go.mod"

Create a makefile to download and install the packages:

qwerty@qwerty-mbp > cat Makefile 
download:
	@echo Download go.mod dependencies
	@go mod download

install-tools: download
	@echo Installing tools from tools.go
	@cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install %

Clear any existing cache:

qwerty@qwerty-mbp > go clean -cache && go clean -modcache

Download and install packages:

qwerty@qwerty-mbp > make -d install-tools

Now rebuild account-service:

qwerty@qwerty-mbp > cd account-service/cmd/server
qwerty@qwerty-mbp > export CGO_ENABLED=0 GOOS=linux GOARCH=amd64 && go build

Which repeats the earlier error:

# optisam-backend/account-service/pkg/api/v1
../../pkg/api/v1/account.pb.gw.go:107:3: undefined: runtime.CamelCaseFieldMask
../../pkg/api/v1/account.pb.gw.go:109:56: not enough arguments in call to runtime.FieldMaskFromRequestBody
	have (io.Reader)
	want (io.Reader, *descriptorpb.DescriptorProto)

Can you offer any further pointers?

Does the account-service api need to be rebuilt? Found under path - optisam-backend/account-service/pkg/api/v1

@dharmjit
Copy link

Hi @sweeny-here, We don't need to add everything as tools because there are only few libraries which is used as tools as well as code dependency.

// +build tools

package tools

import (
	_ "github.com/envoyproxy/protoc-gen-validate"
	_ "github.com/golang/mock/mockgen"
	_ "github.com/golang/protobuf/protoc-gen-go"
	_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway"
	_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger"
)

Can you try to run this command directly as there are 2 $ I am not sure if this will work.

cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install %

Can you try installing the updated version of protoc3 compiler. I will also try to setup this code and check If I am also facing the same error.

@sweeny-here
Copy link
Author

The Makefile has the correct syntax.

If running the command via the shell, then yes the second dollar sign needs to be dropped, as per:

qwerty@qwerty-mbp > pwd
/Users/qwerty/Hme/Tek/lac/sam/optisam-backend

qwerty@qwerty-mbp > cat tools.go | grep _ | awk -F'"' '{print $2}' | xargs -tI % go install %

The protoc compiler has been updated to v3x:

qwerty@qwerty-mbp > brew install protobuf

qwerty@qwerty-mbp > protoc --version
libprotoc 3.12.4

I followed your suggestion and updated the tools.go file and re-ran the makefile. Then switched back account-service directory but the error is persisting, as seen here:

qwerty@qwerty-mbp > pwd
/Users/qwerty/Hme/Tek/lac/sam/optisam-backend/account-service/cmd/server

qwerty@qwerty-mbp > export CGO_ENABLED=0 GOOS=linux GOARCH=amd64 && go build
# optisam-backend/account-service/pkg/api/v1
../../pkg/api/v1/account.pb.gw.go:107:3: undefined: runtime.CamelCaseFieldMask
../../pkg/api/v1/account.pb.gw.go:109:56: not enough arguments in call to runtime.FieldMaskFromRequestBody
	have (io.Reader)
	want (io.Reader, *descriptorpb.DescriptorProto)

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