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

"field type *query.Filtering is not supported in query parameters" #180

Open
mewis opened this issue Nov 21, 2019 · 5 comments
Open

"field type *query.Filtering is not supported in query parameters" #180

mewis opened this issue Nov 21, 2019 · 5 comments

Comments

@mewis
Copy link

mewis commented Nov 21, 2019

HI, I receive this error when calling my api and trying to filter
for example http://localhost:7778/api/clients?filter=key==123

I am trying to use protoc-gen-gorm to generate my services

I have setup in my proto file a message as such

message ListRequest {
    infoblox.api.FieldSelection fields = 1;
    infoblox.api.Pagination paging = 2;
    infoblox.api.Sorting order_by = 3;
    infoblox.api.Filtering filter = 4;
}

service ClientService {

    option (gorm.server).autogen = true;

   rpc List (ListRequest) returns (ListClientsResponse){
        option (google.api.http) = {
            get: "/api/clients"
        };
    };
}

I am using the patched version of gen swagger.

I also have in my server setup for my rest server

mux := runtime.NewServeMux(runtime.WithMetadata(func(ctx context.Context, req *http.Request) metadata.MD {
		return gateway.MetadataAnnotator(ctx, req)
	}))

and for the grpc server

interceptors := []grpc.UnaryServerInterceptor{
		gateway.UnaryServerInterceptor(),
	}

	log.Print("create new grpc server with config")
	server := grpc.NewServer(grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(interceptors...)))

Am I missing something?

Thank you

@Calebjh
Copy link
Contributor

Calebjh commented Nov 21, 2019

Per https://github.com/infobloxopen/atlas-app-toolkit/tree/master/query#filtering the syntax in the query string needs to be _filter=... (leading underscore)
It can be easy to miss, but (as far as I know), something like this is required to translate a query string into a grpc object.

@mewis
Copy link
Author

mewis commented Nov 21, 2019

I did try http://localhost:7778/api/clients?_filter=key==123 I dont get a error but I also dont get any filtering. For list it just returns everything.
I only get an error when using the query param ?filter. Is there maybe something that I am supposed to do to map filter to _filter

@mewis
Copy link
Author

mewis commented Nov 22, 2019

I also found that if I change my proto message to

message ListRequest {
    infoblox.api.Filtering _filter = 1;
}

Then I get the same error when trying with _filter

The error originates from https://github.com/infobloxopen/grpc-gateway/blob/master/runtime/query.go#L329

Any help on this would be very much appreciated.

Thank you

@Calebjh
Copy link
Contributor

Calebjh commented Nov 22, 2019

Hmmm. Based on what you've said so far:

  • used protoc-gen-gorm to generate service,
  • added the annotator to get the query URL and the interceptor to convert it into the Filter object

I'm not seeing any clear errors. Can you enable DB logging

db = db.LogMode(true)

and perhaps insert a logging statement somewhere to see if the Filter object is being set when you include the _filter parameter?

@mewis
Copy link
Author

mewis commented Nov 25, 2019

Hey sorry for late reply. dblog does not print anything so I guess the issue is before any query is made.

dbConn := createDBConn()
defer dbConn.GetConn().Close()
gormDb := dbConn.GetConn()
gormDb = gormDb.LogMode(true)

then later

clientService := &service.ClientService{
  &api.ClientServiceDefaultServer{
    DB: gormDb,
  },
}

my guess is it's something to do with UnaryServerInterceptor

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