superset: docker bug: werkzeug/utils.py" in send_from_directory

Bug description

website img image

docker log -f

werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
2024-09-07 08:36:18,303:INFO:werkzeug:192.168.2.100 - - [07/Sep/2024 08:36:18] "GET /static/assets/images/superset-logo-horiz.png HTTP/1.1" 404 -
2024-09-07 08:36:18,364:INFO:werkzeug:192.168.2.100 - - [07/Sep/2024 08:36:18] "GET /static/appbuilder/css/webfonts/fa-solid-900.woff2 HTTP/1.1" 200 -
2024-09-07 08:36:18,429:WARNING:superset.views.base:HTTPException
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 713, in <lambda>
    view_func=lambda **kw: self_ref().send_static_file(**kw),  # type: ignore # noqa: B950
  File "/usr/local/lib/python3.10/site-packages/flask/scaffold.py", line 331, in send_static_file
    return send_from_directory(
  File "/usr/local/lib/python3.10/site-packages/flask/helpers.py", line 590, in send_from_directory
    return werkzeug.utils.send_from_directory(  # type: ignore[return-value]
  File "/usr/local/lib/python3.10/site-packages/werkzeug/utils.py", line 574, in send_from_directory
    raise NotFound()
werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
2024-09-07 08:36:18,430:INFO:werkzeug:192.168.2.100 - - [07/Sep/2024 08:36:18] "GET /static/assets/images/favicon.png HTTP/1.1" 404 -
2024-09-07 08:36:21,994:INFO:werkzeug:192.168.2.100 - - [07/Sep/2024 08:36:21] "POST /login/ HTTP/1.1" 302 -
2024-09-07 08:36:22,011:INFO:werkzeug:192.168.2.100 - - [07/Sep/2024 08:36:22] "GET / HTTP/1.1" 302 -
2024-09-07 08:36:22,065:DEBUG:superset.stats_logger:[stats_logger] (incr) welcome
2024-09-07 08:36:22,073:INFO:werkzeug:192.168.2.100 - - [07/Sep/2024 08:36:22] "GET /superset/welcome/ HTTP/1.1" 200 -
2024-09-07 08:36:22,157:WARNING:superset.views.base:HTTPException
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 713, in <lambda>
    view_func=lambda **kw: self_ref().send_static_file(**kw),  # type: ignore # noqa: B950
  File "/usr/local/lib/python3.10/site-packages/flask/scaffold.py", line 331, in send_static_file
    return send_from_directory(
  File "/usr/local/lib/python3.10/site-packages/flask/helpers.py", line 590, in send_from_directory
    return werkzeug.utils.send_from_directory(  # type: ignore[return-value]
  File "/usr/local/lib/python3.10/site-packages/werkzeug/utils.py", line 574, in send_from_directory
    raise NotFound()
werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
2024-09-07 08:36:22,158:INFO:werkzeug:192.168.2.100 - - [07/Sep/2024 08:36:22] "GET /static/assets/images/loading.gif HTTP/1.1" 404 -
2024-09-07 08:36:22,167:WARNING:superset.views.base:HTTPException
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 713, in <lambda>
    view_func=lambda **kw: self_ref().send_static_file(**kw),  # type: ignore # noqa: B950
  File "/usr/local/lib/python3.10/site-packages/flask/scaffold.py", line 331, in send_static_file
    return send_from_directory(
  File "/usr/local/lib/python3.10/site-packages/flask/helpers.py", line 590, in send_from_directory
    return werkzeug.utils.send_from_directory(  # type: ignore[return-value]
  File "/usr/local/lib/python3.10/site-packages/werkzeug/utils.py", line 574, in send_from_directory
    raise NotFound()
werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
2024-09-07 08:36:22,167:INFO:werkzeug:192.168.2.100 - - [07/Sep/2024 08:36:22] "GET /static/assets/images/favicon.png HTTP/1.1" 404 -
2024-09-07 08:36:43,056:DEBUG:superset.stats_logger:[stats_logger] (incr) health
2024-09-07 08:36:43,056:INFO:werkzeug:127.0.0.1 - - [07/Sep/2024 08:36:43] "GET /health HTTP/1.1" 200 -
2024-09-07 08:36:53,585:DEBUG:superset.stats_logger:[stats_logger] (incr) welcome
2024-09-07 08:36:53,593:INFO:werkzeug:192.168.2.100 - - [07/Sep/2024 08:36:53] "GET /superset/welcome/ HTTP/1.1" 200 -
2024-09-07 08:36:53,625:WARNING:superset.views.base:HTTPException
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 713, in <lambda>
    view_func=lambda **kw: self_ref().send_static_file(**kw),  # type: ignore # noqa: B950
  File "/usr/local/lib/python3.10/site-packages/flask/scaffold.py", line 331, in send_static_file
    return send_from_directory(
  File "/usr/local/lib/python3.10/site-packages/flask/helpers.py", line 590, in send_from_directory
    return werkzeug.utils.send_from_directory(  # type: ignore[return-value]
  File "/usr/local/lib/python3.10/site-packages/werkzeug/utils.py", line 574, in send_from_directory
    raise NotFound()
werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
2024-09-07 08:36:53,626:INFO:werkzeug:192.168.2.100 - - [07/Sep/2024 08:36:53] "GET /static/assets/images/loading.gif HTTP/1.1" 404 -
2024-09-07 08:37:13,160:DEBUG:superset.stats_logger:[stats_logger] (incr) health
2024-09-07 08:37:13,160:INFO:werkzeug:127.0.0.1 - - [07/Sep/2024 08:37:13] "GET /health HTTP/1.1" 200 -

How to reproduce the bug

  1. superset-4.0.2
  2. sudo docker compose up -d

Screenshots/recordings

No response

Superset version

master / latest-dev

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

  • I have searched Superset docs and Slack and didn’t find a solution to my problem.
  • I have searched the GitHub issue tracker and didn’t find a similar bug report.
  • I have checked Superset’s logs for errors and if I found a relevant Python stacktrace, I included it here as text in the “additional context” section.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 19 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Not sure if/how it would matter, maybe local settings, but why not using http://localhost:8088 instead of http://{ip}:8088

I found some similar issues and discussions that might help you resolve the 404 Not Found errors for static assets in Superset when using Docker:

  1. Closed Issue: GET /ws HTTP/1.1 werkzeug.exceptions.NotFound: 404 Not Found

    • This issue was resolved by ensuring that the static assets are correctly built and copied into the final Docker image [1].
  2. Closed Issue: NotFound errors on 2.0.1rc2

    • The suggested solution was to move to docker-compose and ensure proper setup and configuration [2].
  3. Closed Issue: [Errno 99] Cannot assign requested address in superset_init for docker-compose

    • A non-dev Docker compose file was added to help with frontend assets [3].

To resolve the 404 Not Found errors for static assets, follow these steps:

  1. Verify the build process: Ensure that the npm run build command completes without errors and generates the necessary static assets.

  2. Check the asset paths: Ensure that the paths to the static assets are correct and that they are being copied to the expected location in the final Docker image.

  3. Run the Docker build without skipping the build step: Make sure DEV_MODE is set to false to ensure the assets are built and copied:

    docker build --build-arg DEV_MODE=false -t your-superset-image .
    
  4. Configure Nginx correctly: Ensure that your Nginx configuration is set up to serve the static assets properly. Here is a sample configuration snippet from docker/nginx/nginx.conf:

    server {
        listen 80 default_server;
        server_name  _;
    
        location /ws {
            proxy_pass http://superset_websocket;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header Host $host;
        }
    
        location / {
            proxy_pass http://superset_app;
            proxy_set_header    Host                $host;
            proxy_set_header    X-Real-IP           $remote_addr;
            proxy_set_header    X-Forwarded-For     $remote_addr;
            proxy_set_header    X-Forwarded-Host    $host;
            proxy_set_header    X-Forwarded-Proto   $scheme;
            proxy_http_version 1.1;
            port_in_redirect off;
            proxy_connect_timeout 300;
        }
    }
    

Additionally, ensure that you follow the steps outlined in the Superset Docker documentation for proper setup and configuration:

  1. Prerequisites:

  2. Configuration:

    • The /app/pythonpath folder is mounted from ./docker/pythonpath_dev which contains a base configuration ./docker/pythonpath_dev/superset_config.py intended for use with local development.
    • For local overrides, copy ./docker/pythonpath_dev/superset_config_local.example to ./docker/pythonpath_dev/superset_config_docker.py and fill in your overrides.
  3. Initializing Database:

    • The database will initialize itself upon startup via the init container (superset-init). This may take a minute.
  4. Normal Operation:

    • To run the container, simply run: docker compose up
    • After waiting several minutes for Superset initialization to finish, you can open a browser and view http://localhost:8088.

By following these steps, you should be able to resolve the 404 Not Found errors for static assets in Superset when using Docker [4][5][6].

To continue talking to Dosu, mention @dosu.