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

server panics when field mask is missing #1281

Open
vchudnov-g opened this issue Mar 22, 2023 · 0 comments
Open

server panics when field mask is missing #1281

vchudnov-g opened this issue Mar 22, 2023 · 0 comments
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@vchudnov-g
Copy link
Contributor

If a request is missing a field mask when the server expects it, Showcase panics rather than logging/returning a descriptive error.

I ran into this in the course of investigating #1263.

Reproduction steps:

After starting the server, issue the following requests:

# works; note that if we set the field "name" it gets overriden by the server
curl -H "X-Goog-Api-Client: rest/0.0.0 gapic/0.0.0" -H 'Content-Type: application/json' -i -X POST http://localhost:7469/v1beta1/users -d'{"user":{"displayName":"JaneDoe","email":"janedoe@example.com","nickname":"Doe","heightFeet":5.0,"enableNotifications":true}}'

# works
curl -H "X-Goog-Api-Client: rest/0.0.0 gapic/0.0.0" -H 'Content-Type: application/json' -i -X GET http://localhost:7469/v1beta1/users 

# works
curl -H "X-Goog-Api-Client: rest/0.0.0 gapic/0.0.0" -H 'Content-Type: application/json' -i -X PATCH http://localhost:7469/v1beta1/users/0?updateMask=\"email,heightFeet,enableNotifications\" -d'{"displayName":"JaneDoe","email":"janedoe@jane.com","heightFeet":6.0,"enableNotifications":true}'      

# panics because of missing field mask
curl -H "X-Goog-Api-Client: rest/0.0.0 gapic/0.0.0" -H 'Content-Type: application/json' -i -X PATCH http://localhost:7469/v1beta1/users/0 -d'{"displayName":"JanetDoe","email":"janetdoe@jane.com","heightFeet":7.0,"enableNotifications":true}'
# curl responds with: curl: (52) Empty reply from server

The panic message in the server logs is

2023/03/22 13:34:19 http: panic serving 127.0.0.1:37604: field google.showcase.v1beta1.User.create_time has invalid nil pointer
goroutine 101 [running]:
net/http.(*conn).serve.func1()
        /usr/lib/google-golang/src/net/http/server.go:1853 +0xbf
panic({0xba5de0, 0xc0005b5320})
        /usr/lib/google-golang/src/runtime/panic.go:890 +0x263
google.golang.org/protobuf/internal/impl.fieldInfoForMessage.func4({0xc0001a7200?}, {{}, 0xcb8220?, 0xc0000aa460?, 0xc0000aa740?})
        /usr/local/google/home/vchudnov/VeneerToolkit/compute-gapic/showcase3/gopath/pkg/mod/google.golang.org/protobuf@v1.30.0/internal/impl/message_reflect_field.go:447 +0x20b
google.golang.org/protobuf/internal/impl.(*messageState).Set(0xc0002621b0, {0xe11710?, 0xc0001514d0?}, {{}, 0xcb8220?, 0xc0000aa460?, 0xbfb680?})
        /usr/local/google/home/vchudnov/VeneerToolkit/compute-gapic/showcase3/gopath/pkg/mod/google.golang.org/protobuf@v1.30.0/internal/impl/message_reflect_gen.go:91 +0x10b
github.com/googleapis/gapic-showcase/server/services.applyFieldMask({0xe0c210, 0xc000262090}, {0xe0c210, 0xc0002621b0}, {0x0, 0x0, 0xc82040?})
        /usr/local/google/home/vchudnov/VeneerToolkit/dev/gapic-showcase/server/services/util.go:47 +0x224
github.com/googleapis/gapic-showcase/server/services.(*identityServerImpl).UpdateUser(0xc0003e29c0, {0xc00045c630?, 0xba40a0?}, 0xdf9f90?)
        /usr/local/google/home/vchudnov/VeneerToolkit/dev/gapic-showcase/server/services/identity_service.go:131 +0x24d
github.com/googleapis/gapic-showcase/server/genrest.(*RESTBackend).HandleUpdateUser(0xc0003cfe40, {0xe04be0, 0xc000213960}, 0xc000423300)
        /usr/local/google/home/vchudnov/VeneerToolkit/dev/gapic-showcase/server/genrest/identity.go:229 +0xaa3
net/http.HandlerFunc.ServeHTTP(0xc000423200?, {0xe04be0?, 0xc000213960?}, 0xc0000a29e8?)
        /usr/lib/google-golang/src/net/http/server.go:2121 +0x2f
github.com/gorilla/mux.(*Router).ServeHTTP(0xc000000e40, {0xe04be0, 0xc000213960}, 0xc000423100)
        /usr/local/google/home/vchudnov/VeneerToolkit/compute-gapic/showcase3/gopath/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1cf
net/http.serverHandler.ServeHTTP({0xe02188?}, {0xe04be0, 0xc000213960}, 0xc000423100)
        /usr/lib/google-golang/src/net/http/server.go:2935 +0x316
net/http.(*conn).serve(0xc0001fa870, {0xe05500, 0xc0005a2e70})
        /usr/lib/google-golang/src/net/http/server.go:1994 +0x612
created by net/http.(*Server).Serve
        /usr/lib/google-golang/src/net/http/server.go:3090 +0x61b
@vchudnov-g vchudnov-g added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

1 participant