{"record":{"id":"6d3f77476888b59d","repo":"can1357/oh-my-pi","slug":"frontend-bundle-missing-at-index-path-run-bun","errorCode":null,"errorMessage":"frontend bundle missing at {_INDEX_PATH}; run `bun run web:build`","messagePattern":"frontend bundle missing at (.+?); run `bun run web:build`","errorType":"exception","errorClass":"DashboardBundleMissing","httpStatus":null,"severity":"error","filePath":"python/robomp/src/dashboard.py","lineNumber":101,"sourceCode":"    \"\"\"Filesystem path the FastAPI app mounts at `/static`.\n\n    Creates the directory lazily so a fresh checkout (or a runtime container\n    that hasn't shipped the bundle yet) can still construct the app —\n    `_load_index_template()` raises `DashboardBundleMissing` separately when\n    the `index.html` itself is missing. Without this mkdir,\n    `StaticFiles(directory=...)` would raise at app construction time and\n    block every other route.\n    \"\"\"\n    _STATIC_DIR.mkdir(parents=True, exist_ok=True)\n    return _STATIC_DIR\n\n\n@cache\ndef _load_index_template() -> str:\n    try:\n        text = _INDEX_PATH.read_text(encoding=\"utf-8\")\n    except FileNotFoundError as exc:  # pragma: no cover — repo ships the stub\n        raise DashboardBundleMissing(f\"frontend bundle missing at {_INDEX_PATH}; run `bun run web:build`\") from exc\n    if _CONFIG_SENTINEL not in text:\n        raise DashboardBundleMissing(\n            f\"frontend bundle at {_INDEX_PATH} is missing the {_CONFIG_SENTINEL} sentinel; \"\n            \"rebuild with `bun run web:build`\"\n        )\n    return text\n\n\ndef reset_index_cache() -> None:\n    \"\"\"Drop the cached template. Called by tests that swap the static dir.\"\"\"\n    _load_index_template.cache_clear()\n\n\ndef render_index(replay_token: str | None) -> str:\n    \"\"\"Render the dashboard HTML with the server's replay token baked in.\n\n    The token lands inside a `<script type=\"application/json\">` block that the\n    page parses at startup and attaches to every privileged fetch. The user","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/python/robomp/src/dashboard.py#L83-L119","documentation":"`_load_index_template` reads the built frontend `index.html` at `_INDEX_PATH`; when the file does not exist it raises `DashboardBundleMissing` with this message. The library requires a built web bundle (produced by `bun run web:build`) to serve the dashboard, and refuses to render a broken/absent page.","triggerScenarios":"Calling `render_index` (which invokes `_load_index_template`) when the frontend bundle has never been built, was deleted by a clean, or `_INDEX_PATH` points at a path where the build output was not placed.","commonSituations":"Running the server from a fresh clone without building the web UI, deploying only the Python package without the build artifact, pointing a custom bundle path at a nonexistent directory.","solutions":["Run `bun run web:build` from the repo root to generate the bundle","Verify the build output landed at the path _INDEX_PATH expects (check for index.html)","If deploying, include the built frontend artifact in your deployment package","If a custom path is configured, confirm it matches the actual build output directory"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"from pathlib import Path\nif not _INDEX_PATH.is_file():\n    raise RuntimeError(\"frontend bundle missing — run `bun run web:build` before starting the server\")","typeGuard":null,"tryCatchPattern":"try:\n    html = render_index()\nexcept DashboardBundleMissing:\n    return HTTPResponse(\"Dashboard not built. Run: bun run web:build\", status=503)","preventionTips":["Add `bun run web:build` to your deploy/startup script before launching the server","Check the bundle path exists in a startup preflight","Exclude web build artifacts from `make clean` targets used before deployment","Pin CI to build the web bundle in the same job that runs the server"],"tags":["build","frontend","deployment","dashboard"],"backgroundTag":"missing-build-artifact","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}