Fixed
Status Update
Comments
ni...@gardentechno.com <ni...@gardentechno.com> #2
The code in ~google_cloud_sdk/platform/google_appengine/tools/devappserver2/module.py is very clear about what is does in the method _create_url_handlers:
# Add user-defined URL handlers
for url_map in self._module_configuration.handlers:
handler_type = url_map.GetHandlerType()
if handler_type == appinfo.HANDLER_SCRIPT:
if not self._is_modern():
# Handle script only for traditional runtimes.
handlers.append(_ScriptHandler(url_map))
# ... code removed for brevity ...
if self._is_modern():
# Modern runtimes use default handler to route to user defined entrypoint.
# This handler should be checked after all other handlers.
default_handler = _ScriptHandler(appinfo.URLMap(url='/.*'))
handlers.append(default_handler)
And what this code does is very different from what the documentation says.
# Add user-defined URL handlers
for url_map in self._module_configuration.handlers:
handler_type = url_map.GetHandlerType()
if handler_type == appinfo.HANDLER_SCRIPT:
if not self._is_modern():
# Handle script only for traditional runtimes.
handlers.append(_ScriptHandler(url_map))
# ... code removed for brevity ...
if self._is_modern():
# Modern runtimes use default handler to route to user defined entrypoint.
# This handler should be checked after all other handlers.
default_handler = _ScriptHandler(appinfo.URLMap(url='/.*'))
handlers.append(default_handler)
And what this code does is very different from what the documentation says.
al...@google.com <al...@google.com> #3
I have tried to reproduced your scenario using the same yaml configuration in Go1.11. I have created that directory structure and also an 'index.html" file, but everything works out fine. The root directory shows me my 'index.html', since it is the first match in the handlers (' - url: /$ '), and when I access my endpoint '/api/signup/', it is indeed handled by my application, going to my specified endpoint. Could you specify what static document is that one that is not found?
ni...@gardentechno.com <ni...@gardentechno.com> #4
Hello,
Weird. Here is a reproducer, to make sure we run the same code:
- Checkouthttps://github.com/ngrilly/test-gae-handlers
- Start the server with `dev_appserver.py .`
- Visithttp://localhost:8080/ . It should return "Hello from static handler".
- Visithttp://localhost:8080/api/signup . It should return "Hello from Go", but it returns a 404 instead.
When I hit /api/signup, I got a 404 and it looks like the Go server never got the request.
Weird. Here is a reproducer, to make sure we run the same code:
- Checkout
- Start the server with `dev_appserver.py .`
- Visit
- Visit
When I hit /api/signup, I got a 404 and it looks like the Go server never got the request.
al...@google.com <al...@google.com> #5
Thank you for providing the reproduction details. I have forwarded the details to the App Engine engineering team, and it's currently being investigated.
ni...@gardentechno.com <ni...@gardentechno.com> #6
Thanks! Have you been able to reproduce the issue using the code I shared?
ap...@google.com <ap...@google.com> #7
🤖 This is an automatic update. The status of the related internal issue(s) listed in "Blocked By" has changed, so we've done the following:
* Updated the status to Accepted, because an engineer has begun work on the related issue.
You can read more about what these statuses mean athttps://developers.google.com/issue-tracker/concepts/issues#fields
* Updated the status to Accepted, because an engineer has begun work on the related issue.
You can read more about what these statuses mean at
dh...@google.com <dh...@google.com> #8
This is an issue in dev_appserver in which:
-it serves the app from /app, but the routable URI includes /app/ when passed to the language. All routes defined in the user's app must include it as a prefix.
-Serves static from /
In production it works as expected though.
The App Engine product team is already aware and are working on a fix to be released possibly in the next Cloud SDK version. In the meantime there's a workaround:
You can apply this diff to the `devappserver2/module.py` file:
--- ./platform/google_appengine/google/appengine/tools/devappserver2/module.py.old
+++ ./platform/google_appengine/google/appengine/tools/devappserver2/module.py
@@ -289,9 +289,7 @@
for url_map in self._module_configuration.handlers:
handler_type = url_map.GetHandlerType()
if handler_type == appinfo.HANDLER_SCRIPT:
- if not self._is_modern():
- # Handle script only for traditional runtimes.
- handlers.append(_ScriptHandler(url_map))
+ handlers.append(_ScriptHandler(url_map))
if not found_start_handler and re.match('%s$' % url_map.url,
'/_ah/start'):
found_start_handler = True
You can find this file at $(dirname $(which dev_appserver.py))/../platform/google_appengine/google/appengine/tools/devappserver2/module.py
-it serves the app from /app, but the routable URI includes /app/ when passed to the language. All routes defined in the user's app must include it as a prefix.
-Serves static from /
In production it works as expected though.
The App Engine product team is already aware and are working on a fix to be released possibly in the next Cloud SDK version. In the meantime there's a workaround:
You can apply this diff to the `devappserver2/module.py` file:
--- ./platform/google_appengine/google/appengine/tools/devappserver2/module.py.old
+++ ./platform/google_appengine/google/appengine/tools/devappserver2/module.py
@@ -289,9 +289,7 @@
for url_map in self._module_configuration.handlers:
handler_type = url_map.GetHandlerType()
if handler_type == appinfo.HANDLER_SCRIPT:
- if not self._is_modern():
- # Handle script only for traditional runtimes.
- handlers.append(_ScriptHandler(url_map))
+ handlers.append(_ScriptHandler(url_map))
if not found_start_handler and re.match('%s$' % url_map.url,
'/_ah/start'):
found_start_handler = True
You can find this file at $(dirname $(which dev_appserver.py))/../platform/google_appengine/google/appengine/tools/devappserver2/module.py
vi...@google.com <vi...@google.com> #9
Hello,
A fix for this issue with the dev_appserver was released. Updating the Cloud SDK solves the issue[1][2].
Please open another Public Issue if this happens again
────────────────────
[1]:https://cloud.google.com/sdk/install
[2]:https://cloud.google.com/sdk/gcloud/reference/components/update
A fix for this issue with the dev_appserver was released. Updating the Cloud SDK solves the issue[1][2].
Please open another Public Issue if this happens again
────────────────────
[1]:
[2]:
Description
Handlers defined in app.yaml with the attribute "script: auto" are ignored when using modern runtimes Python 3.7 and Go 1.11.
What you expected to happen:
I expect the first matching handler to be used, whereas it's a static handler or a "script" handler.
Steps to reproduce:
Let's use the following app.yaml:
runtime: go111
handlers:
- url: /api/.*
script: auto
- url: /$
static_files: dist/index.html
upload: dist/index.html
- url: /
static_dir: dist
I expect an HTTP request to /api/signup to be served by my Go application. Instead, it tries to find a static file that doesn't exist and return a 404.
Other information (workarounds you have tried, documentation consulted, etc):
According to the documentation, “App Engine can handle URLs by executing application code, or by serving static files uploaded with the code, such as images, CSS, or JavaScript. Patterns are evaluated in the order they appear in the app.yaml file, from top to bottom. The first mapping whose pattern matches the URL is the one used to handle the request.”
According to the documentation, the optional script attribute “specifies that requests to the specific handler should target your app. The only accepted value for the script element is auto because all traffic is served using the entrypoint command. In order to use static handlers, at least one of your handlers must contain the line script: auto to deploy successfully.”
Source: