{"record":{"id":"7688c52b986553d3","repo":"BoundaryML/baml","slug":"invalid-baml-playground-dev-port-e","errorCode":null,"errorMessage":"Invalid BAML_PLAYGROUND_DEV_PORT: {e}","messagePattern":"Invalid BAML_PLAYGROUND_DEV_PORT: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_lsp_server/src/playground_server.rs","lineNumber":873,"sourceCode":"    };\n\n    let api = Router::new()\n        .route(\"/api/ws\", get(playground_ws_handler))\n        .route(\"/api/lsp\", get(lsp_ws_handler))\n        .route(\"/api/source-files\", get(source_files_handler))\n        .with_state(ws_state)\n        .layer(middleware::from_fn_with_state(\n            access_guard,\n            api_guard_middleware,\n        ));\n\n    let fallback = if let Some(dir) = playground_dir_override {\n        tracing::info!(\"Playground: serving static files from {}\", dir.display());\n        static_router(dir.to_string_lossy().into_owned())\n    } else if let Ok(dev_port) = std::env::var(\"BAML_PLAYGROUND_DEV_PORT\") {\n        let dev_port: u16 = dev_port\n            .parse()\n            .map_err(|e| anyhow::anyhow!(\"Invalid BAML_PLAYGROUND_DEV_PORT: {e}\"))?;\n        tracing::info!(\"Playground: dev proxy -> http://localhost:{dev_port}\");\n        dev_proxy_router(format!(\"http://localhost:{dev_port}\"))\n    } else if let Ok(dir) = std::env::var(\"BAML_PLAYGROUND_DIR\") {\n        tracing::info!(\"Playground: serving static files from {dir}\");\n        static_router(dir)\n    } else {\n        return Err(PlaygroundNotConfigured.into());\n    };\n\n    Ok(api.fallback_service(fallback))\n}\n\nfn history_project_root_for_project(project: &str) -> PathBuf {\n    let fs_path = bex_project::FsPath::from_str(project.to_string());\n    bex_events::history::path::resolve_project_root(fs_path.as_path())\n}\n\n// ---------------------------------------------------------------------------","sourceCodeStart":855,"sourceCodeEnd":891,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_lsp_server/src/playground_server.rs#L855-L891","documentation":"When BAML_PLAYGROUND_DEV_PORT is set, its value is parsed as u16 to build a dev-proxy router. If the value is not a valid unsigned integer (or outside u16), the parse error is wrapped in this anyhow message and startup aborts. The env var is present but malformed.","triggerScenarios":"Setting BAML_PLAYGROUND_DEV_PORT to a non-numeric string (e.g. \"http://localhost:3000\"), a value with whitespace/quotes, a negative number, or a number above 65535; then starting the playground server without BAML_PLAYGROUND_DIR.","commonSituations":"Pasting a full URL instead of just the port into the env var; quoting issues in shell config leaving stray characters; typos like \"3O00\"; copy-pasting the whole dev server address from Vite output.","solutions":["Set BAML_PLAYGROUND_DEV_PORT to a bare numeric port within 0-65535, e.g. 3000.","Remove surrounding quotes/whitespace from the value in your shell config.","Alternatively unset BAML_PLAYGROUND_DEV_PORT and set BAML_PLAYGROUND_DIR to static assets instead.","Verify with: echo $BAML_PLAYGROUND_DEV_PORT"],"exampleFix":"// before\nexport BAML_PLAYGROUND_DEV_PORT=http://localhost:3000\n\n// after\nexport BAML_PLAYGROUND_DEV_PORT=3000","handlingStrategy":"validation","validationCode":"if let Ok(v) = std::env::var(\"BAML_PLAYGROUND_DEV_PORT\") {\n    let ok = v.trim().parse::<u16>().is_ok();\n    if !ok { eprintln!(\"BAML_PLAYGROUND_DEV_PORT must be a port number 0-65535, got: {v}\"); }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set the env var to a bare integer port, never a URL","Check values in shell profiles for stray quotes/whitespace","Prefer BAML_PLAYGROUND_DIR when no dev server is running"],"tags":["rust","configuration","env-var","port"],"backgroundTag":"invalid-env-var-value","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"}