#6187·mage-ai

[BUG] Intermittent base path initialization failure causes Mage to start with default routes and workspace to return 404

Author: the-archbishopCreated Sep 28, 2026Updated Sep 28, 2026
Labelsbug

Mage version

0.9.77

Describe the bug

We have intermittently seen Mage workspaces become inaccessible after pod recreation for several months. When this occurs, the affected workspace returns HTTP 404 at its configured base path even though the pod is running and the Kubernetes ingress/service configuration appears correct.

Historically, recreating the affected workspace pod has restored service. Because the issue is intermittent and pod recreation also removes the failing instance, we had not previously been able to identify the underlying application behavior.

We recently added external synthetic monitoring of each workspace's actual base-path URL. This allowed us to detect an occurrence on a workspace configured with: MAGE_BASE_PATH=corp-assets-orchestration and preserve enough logging to identify what happened during startup.

During startup, Mage attempted to configure the base path but failed while removing the existing frontend directory in replace_base_path():

2026-09-28 15:17:14,531 WARNING mage_ai.server.server main:580
Server failed to replace base path with error:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/mage_ai/server/server.py", line 576, in main
    template_dir = replace_base_path(REQUESTS_BASE_PATH)
  File "/usr/local/lib/python3.10/site-packages/mage_ai/server/server.py", line 218, in replace_base_path
    shutil.rmtree(dst)
  File "/usr/local/lib/python3.10/shutil.py", line 725, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/usr/local/lib/python3.10/shutil.py", line 658, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/local/lib/python3.10/shutil.py", line 658, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/local/lib/python3.10/shutil.py", line 658, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/local/lib/python3.10/shutil.py", line 681, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
  File "/usr/local/lib/python3.10/shutil.py", line 679, in _rmtree_safe_fd
    os.unlink(entry.name, dir_fd=topfd)
FileNotFoundError: [Errno 2] No such file or directory: '7849-e52eeca7d1a2b973.js.LICENSE.txt'

Mage then explicitly fell back to its default routes and continued startup:

2026-09-28 15:17:14,532 WARNING mage_ai.server.server main:584
Continuing with default routes...

2026-09-28 15:17:14,661 INFO mage_ai.server.server main:616
Mage is running at http://localhost:6789 and serving project /home/src/corp-assets-orchestration

For comparison, a healthy startup of the same workspace logs:

Mage is running at http://localhost:6789/corp-assets-orchestration

Once Mage continued with the default routes:

  • / continued returning HTTP 200.
  • /corp-assets-orchestration and its API/WebSocket paths returned HTTP 404.
  • The scheduler continued running.
  • The pod remained running and did not recover automatically.
  • We observed 155 HTTP 404 responses to the configured base path and no successful responses during the affected period.

This resulted in a workspace that appeared healthy at the infrastructure level but was inaccessible through its configured base path.

To reproduce

We do not currently have a reliable reproduction.

The issue occurs intermittently during pod recreation. Most pod recreations complete successfully, which has made the issue difficult to capture.

The sequence observed during this occurrence was:

  1. Run Mage with MAGE_BASE_PATH=corp-assets-orchestration.
  2. Recreate the Mage workspace pod.
  3. During startup, replace_base_path(REQUESTS_BASE_PATH) calls shutil.rmtree(dst).
  4. shutil.rmtree() encounters a FileNotFoundError while attempting to remove: 7849-e52eeca7d1a2b973.js.LICENSE.txt
  5. Mage catches the failure and logs: Continuing with default routes...
  6. Mage completes startup at http://localhost:6789 rather than http://localhost:6789/corp-assets-orchestration.
  7. / returns HTTP 200 while requests under /corp-assets-orchestration return HTTP 404.

We have not identified what caused the file to disappear during shutil.rmtree(). No permission, read-only filesystem, or related filesystem errors were observed around the failure.

Expected behavior

When MAGE_BASE_PATH is explicitly configured, a failure to initialize that base path should not leave Mage running indefinitely in a state where the configured workspace URL is unavailable.

Ideally, Mage should either:

  • handle/retry the transient filesystem condition and successfully configure the requested base path, or
  • fail startup/readiness so Kubernetes can recreate the unhealthy pod.

Falling back to default routes allows the application to appear healthy while the configured workspace endpoint returns HTTP 404.

Screenshots

No response

Operating system

No response

Additional context

We have observed the same general failure mode intermittently across multiple Mage workspaces for several months without having any idea when it was occurring.

Recreating the affected pod has historically restored the workspace.

For this occurrence, the affected pod remained in the broken state for approximately 38 minutes until we manually deleted it.

No ingress, service, Mage configuration, or image changes were made as part of the recovery.