{"record":{"id":"63224ea03a6f5a2f","repo":"BoundaryML/baml","slug":"playground-server-requires-either-baml-playground-dev-port","errorCode":null,"errorMessage":"Playground server requires either BAML_PLAYGROUND_DEV_PORT or BAML_PLAYGROUND_DIR","messagePattern":"Playground server requires either BAML_PLAYGROUND_DEV_PORT or BAML_PLAYGROUND_DIR","errorType":"exception","errorClass":"PlaygroundNotConfigured","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_lsp_server/src/playground_server.rs","lineNumber":71,"sourceCode":"    playground_runs::{\n        overlay_function_name_for_target, patch_to_wire, run_summary_to_wire, run_to_wire,\n    },\n    playground_seam::{PlaygroundSeam, PlaygroundSourceFile},\n    playground_ws::{RunListFilter, RunListKind, RunListVisibility, WsInMessage, WsOutMessage},\n};\n\n/// Telemetry reads one session may run at once. Small on purpose: these are\n/// `DataFusion` queries and CAS reads, and a panel needs a couple in flight\n/// (the list plus the open execution), not a backlog.\nconst MAX_INFLIGHT_TELEMETRY: usize = 4;\n\n/// Reported when that ceiling is reached. The client treats it as \"skip this\n/// refresh\" rather than as a failure, because the common cause is its own\n/// polling outrunning a slow query.\nconst TELEMETRY_BUSY_CODE: &str = \"telemetryBusy\";\n\n#[derive(Debug, thiserror::Error)]\n#[error(\"Playground server requires either BAML_PLAYGROUND_DEV_PORT or BAML_PLAYGROUND_DIR\")]\npub struct PlaygroundNotConfigured;\n\nfn to_ws_text(msg: &WsOutMessage) -> Option<AxumWsMsg> {\n    match serde_json::to_string(msg) {\n        Ok(json) => Some(AxumWsMsg::Text(json.into())),\n        Err(e) => {\n            tracing::error!(\"Playground WS: failed to serialize message: {e}\");\n            None\n        }\n    }\n}\n\nfn epoch_ms() -> u64 {\n    let millis = std::time::SystemTime::now()\n        .duration_since(std::time::UNIX_EPOCH)\n        .unwrap_or_default()\n        .as_millis();\n    u64::try_from(millis).unwrap_or(u64::MAX)","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_lsp_server/src/playground_server.rs#L53-L89","documentation":"PlaygroundNotConfigured is a thiserror error thrown when the LSP playground server is started without any way to serve the frontend. The server needs either a Vite dev-server port (BAML_PLAYGROUND_DEV_PORT) to proxy to, or a directory of prebuilt static assets (BAML_PLAYGROUND_DIR). If neither env var is set, there is no UI to serve and startup is aborted.","triggerScenarios":"Starting the playground server via run/build_router with neither BAML_PLAYGROUND_DEV_PORT nor BAML_PLAYGROUND_DIR present in the environment; e.g. running the LSP server in production without the packaged playground assets and without a dev server.","commonSituations":"Developers running the LSP server from source without a Vite dev server; CI/headless environments where env vars were not exported; a wrapper process stripping environment variables; expecting the binary to bundle assets but BAML_PLAYGROUND_DIR unset.","solutions":["Set BAML_PLAYGROUND_DIR to the directory containing the built playground static assets (e.g. baml_studio build output).","Or set BAML_PLAYGROUND_DEV_PORT to the port of a running Vite dev server (e.g. 3000) to proxy UI requests.","Use the packaged/production binary that ships with bundled playground assets instead of a from-source run.","Export the env var in your shell profile or launcher so child LSP processes inherit it."],"exampleFix":"// before\n// no env vars set -> PlaygroundNotConfigured\n// spawn_lsp()\n\n// after\n// BAML_PLAYGROUND_DIR=./baml_studio/dist spawn_lsp()","handlingStrategy":"validation","validationCode":"if std::env::var(\"BAML_PLAYGROUND_DEV_PORT\").is_err()\n    && std::env::var(\"BAML_PLAYGROUND_DIR\").is_err()\n{\n    eprintln!(\"playground disabled: set BAML_PLAYGROUND_DEV_PORT or BAML_PLAYGROUND_DIR\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always export one of BAML_PLAYGROUND_DIR or BAML_PLAYGROUND_DEV_PORT in the launcher environment","Use a wrapper script that fails fast with a clear message when neither var is set","Prefer the packaged binary with bundled assets in production"],"tags":["rust","lsp","configuration","missing-env-var"],"backgroundTag":"missing-env-var","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}