Title: Passing JSON value other than an object in request body results in 500 Internal Server Error · Issue #192 · cloudendpoints/endpoints-python · GitHub
Open Graph Title: Passing JSON value other than an object in request body results in 500 Internal Server Error · Issue #192 · cloudendpoints/endpoints-python
X Title: Passing JSON value other than an object in request body results in 500 Internal Server Error · Issue #192 · cloudendpoints/endpoints-python
Description: When the client sends a POST request that consists of any other JSON value besides a JSON object, e.g, a string or an array, the endpoints framework returns with 500 Internal Server Error. Would expert a 400 Bad Request error for parsing...
Open Graph Description: When the client sends a POST request that consists of any other JSON value besides a JSON object, e.g, a string or an array, the endpoints framework returns with 500 Internal Server Error. Would ex...
X Description: When the client sends a POST request that consists of any other JSON value besides a JSON object, e.g, a string or an array, the endpoints framework returns with 500 Internal Server Error. Would ex...
Opengraph URL: https://github.com/cloudendpoints/endpoints-python/issues/192
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Passing JSON value other than an object in request body results in 500 Internal Server Error","articleBody":"When the client sends a POST request that consists of any other JSON value besides a JSON object, e.g, a string or an array, the endpoints framework returns with 500 Internal Server Error. Would expert a 400 Bad Request error for parsing ProtoRPC request.\r\n\r\nTo reproduce, e.g., use [the echo example](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/endpoints-frameworks-v2/echo).\r\nExample queries returning 500:\r\n\r\n`curl https://\u003cYOUR-PROJECT-ID\u003e.appspot.com/_ah/api/echo/v1/echo -H \"Content-Type: application/json\" -d '\"hello world\"'`\r\n\r\n`curl https://\u003cYOUR-PROJECT-ID\u003e.appspot.com/_ah/api/echo/v1/echo -H \"Content-Type: application/json\" -d '[\"hello\", \"world\"]'`\r\n\r\nLog message:\r\n```\r\nTraceback (most recent call last):\r\n File \"/base/alloc/tmpfs/dynamic_runtimes/python27g/7679791231c143f9/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py\", line 267, in Handle\r\n result = handler(dict(self._environ), self._StartResponse)\r\n File \"/base/data/home/apps/s~peeter-sandbox/20190418t084040.417569099234297404/lib/endpoints_management/control/wsgi.py\", line 166, in __call__\r\n return self.wsgi_backend(environ, start_response)\r\n File \"/base/data/home/apps/s~peeter-sandbox/20190418t084040.417569099234297404/lib/endpoints_management/control/wsgi.py\", line 278, in __call__\r\n return self._application(environ, start_response)\r\n File \"/base/data/home/apps/s~peeter-sandbox/20190418t084040.417569099234297404/lib/endpoints_management/control/wsgi.py\", line 723, in __call__\r\n return self._application(environ, start_response)\r\n File \"/base/data/home/apps/s~peeter-sandbox/20190418t084040.417569099234297404/lib/endpoints_management/control/wsgi.py\", line 415, in __call__\r\n result = b''.join(result)\r\n File \"/base/data/home/apps/s~peeter-sandbox/20190418t084040.417569099234297404/lib/endpoints/endpoints_dispatcher.py\", line 147, in __call__\r\n yield self.dispatch(request, start_response)\r\n File \"/base/data/home/apps/s~peeter-sandbox/20190418t084040.417569099234297404/lib/endpoints/endpoints_dispatcher.py\", line 170, in dispatch\r\n return self.call_backend(request, start_response)\r\n File \"/base/data/home/apps/s~peeter-sandbox/20190418t084040.417569099234297404/lib/endpoints/endpoints_dispatcher.py\", line 337, in call_backend\r\n orig_request, params, method_config)\r\n File \"/base/data/home/apps/s~peeter-sandbox/20190418t084040.417569099234297404/lib/endpoints/endpoints_dispatcher.py\", line 510, in transform_request\r\n request = self.transform_rest_request(orig_request, params, method_params)\r\n File \"/base/data/home/apps/s~peeter-sandbox/20190418t084040.417569099234297404/lib/endpoints/endpoints_dispatcher.py\", line 641, in transform_rest_request\r\n self._update_from_body(body_json, request.body_json)\r\n File \"/base/data/home/apps/s~peeter-sandbox/20190418t084040.417569099234297404/lib/endpoints/endpoints_dispatcher.py\", line 552, in _update_from_body\r\n for key, value in source.iteritems():\r\nAttributeError: 'unicode' object has no attribute 'iteritems'\"\r\n```\r\n\r\nFor me it seems, that in the `endpoints_dispatcher.py`, `_update_from_body` functions just assumes that the given `request.body_json` is a dict without providing a graceful fallback.","author":{"url":"https://github.com/ppik","@type":"Person","name":"ppik"},"datePublished":"2019-04-18T10:35:08.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/192/endpoints-python/issues/192"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ec98c19b-95a5-45de-f5f0-8209108bfb9f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9148:645E3:618450:8FB342:6A4E1027 |
| html-safe-nonce | e22bf931d6a7e8d41b0737537a1adf2af4a36bd97bb38a99436abe4cfcc705cc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MTQ4OjY0NUUzOjYxODQ1MDo4RkIzNDI6NkE0RTEwMjciLCJ2aXNpdG9yX2lkIjoiMTk5NzQ3NTk4OTkxNTgzMjM2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a2b8140994778739cdce2116469bfc2867ab337c09f459e99e3e344f8bea9ebf |
| hovercard-subject-tag | issue:434702303 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/cloudendpoints/endpoints-python/192/issue_layout |
| twitter:image | https://opengraph.githubassets.com/576f0c081582df1fca03c2ffc5fe3295abafc53f5d11ecf92fac1b1d168c89fa/cloudendpoints/endpoints-python/issues/192 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/576f0c081582df1fca03c2ffc5fe3295abafc53f5d11ecf92fac1b1d168c89fa/cloudendpoints/endpoints-python/issues/192 |
| og:image:alt | When the client sends a POST request that consists of any other JSON value besides a JSON object, e.g, a string or an array, the endpoints framework returns with 500 Internal Server Error. Would ex... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ppik |
| hostname | github.com |
| expected-hostname | github.com |
| None | df0492960db29b4938cb72070351d6b1d0c6c0767b27ceb8394bbf4fcc0223c6 |
| turbo-cache-control | no-preview |
| go-import | github.com/cloudendpoints/endpoints-python git https://github.com/cloudendpoints/endpoints-python.git |
| octolytics-dimension-user_id | 19231370 |
| octolytics-dimension-user_login | cloudendpoints |
| octolytics-dimension-repository_id | 65349604 |
| octolytics-dimension-repository_nwo | cloudendpoints/endpoints-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 65349604 |
| octolytics-dimension-repository_network_root_nwo | cloudendpoints/endpoints-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 51470c353b8a1f52a88d3e3cc2014b17ab8cc1ce |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width