google-code-export / appengine-devappserver2-experiment

Automatically exported from code.google.com/p/appengine-devappserver2-experiment
0 stars 0 forks source link

Query and template param values convertion in SPI input (Cloud Endpoints) #67

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Consider this message definition (snippet from a discovery doc):

  "TestMessage": {
    "id": "TestMessage",
    "type": "object",
    "properties": {
      "a": { "type": "integer", "format": "int32" },
      "b": { "type": "number", "format": "float" },
      "c": { "type": "number", "format": "double" },
      "d": { "type": "boolean" }
    }
  }

and a path template of a service method that accepts the above message:

  "test/{a}/{b}/{c}"

Then, a request like this:

  GET /_ah/api/myapi/v1/test/1/2/3?d=true

will result in the following JSON body (as read by an SPI backend) on *dev* 
server:

  {"a": "1", "b": "2", "c": "3", "d": "true"}

That is, int32, float, double and booleans are not converted to their real 
values.
In production environment this correctly results in:

  {"a": 1, "b": 2.0, "c": 3.0, "d": true}

I think this has never been raised before because Python's implementation is 
based on ProtoRPC which has its own decoder. The issue comes up when using an 
alternative SPI server implementation. Specifically, Go version: 
https://github.com/crhym3/go-endpoints/issues/5

From what I can tell, looks like this should be happening somewhere around 
transform_rest_request() method:
https://code.google.com/p/appengine-devappserver2-experiment/source/browse/googl
e/appengine/tools/devappserver2/endpoints/endpoints_server.py?spec=svn503af98c6a
f81db7006cfaa45da2c999b47b66a7&r=503af98c6af81db7006cfaa45da2c999b47b66a7#456

And here's the link to official SDK release version (1.8.0):
https://code.google.com/p/googleappengine/source/browse/trunk/python/google/appe
ngine/tools/devappserver2/endpoints/endpoints_server.py?spec=svn346&r=345#570

(I noticed they are slightly different and didn't know which one to choose)

Let me guys know if this makes sense and/or you need more info, or talk to 
dhermes@google.

Original issue reported on code.google.com by a...@cloudware.it on 31 May 2013 at 6:32

GoogleCodeExporter commented 9 years ago
Does this bug need to be addressed in a more timely fashion now that 
go-endpoints is moved to the GoogleCloudPlatform github project 
(https://github.com/GoogleCloudPlatform/go-endpoints)?

Original comment by iannu...@google.com on 27 Jan 2015 at 2:40

GoogleCodeExporter commented 9 years ago
I'll talk to Francesc about this. Should meet him soon, beginning of the next 
week.

Original comment by crh...@google.com on 29 Jan 2015 at 10:22