{"record":{"id":"0e2b1353d3bdd1d8","repo":"t8y2/dbx","slug":"invalid-dbx-web-mcp-configuration","errorCode":null,"errorMessage":"Invalid DBX Web MCP configuration","messagePattern":"Invalid DBX Web MCP configuration","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbx-web/src/main.rs","lineNumber":1103,"sourceCode":"        .route(\"/cloud-sync/snippet/download\", post(routes::cloud_sync::snippet_sync_download));\n\n    // Do not expose DuckDB-only handlers from builds that omit DuckDB sidecar support.\n    #[cfg(feature = \"duckdb-sidecar\")]\n    let api =\n        api.route(\"/query/build-duckdb-attach-database-sql\", post(routes::query::build_duckdb_attach_database_sql));\n\n    let api = add_mq_routes(api)\n        .layer(middleware::from_fn_with_state(web_state.clone(), auth::auth_middleware))\n        .with_state(web_state.clone());\n\n    // Build app\n    let mut app = Router::new()\n        .nest(\"/api\", api)\n        .layer(DefaultBodyLimit::max(web_body_limit_bytes()))\n        .layer(CompressionLayer::new().compress_when(web_compression_predicate()))\n        .layer(tower_http::trace::TraceLayer::new_for_http());\n\n    if let Some(mcp_router) = web_mcp_router(&web_state).expect(\"Invalid DBX Web MCP configuration\") {\n        app = app.merge(mcp_router);\n        tracing::info!(\"DBX Web MCP is enabled at /mcp\");\n    }\n\n    let static_dir = std::env::var_os(\"DBX_STATIC_DIR\").map(std::path::PathBuf::from);\n    app = mount_public_base_path(app, &public_base_path, static_dir.as_deref());\n\n    // Bind address\n    let port: u16 = std::env::var(\"DBX_PORT\").ok().and_then(|p| p.parse().ok()).unwrap_or(4224);\n    let addr = SocketAddr::from(([0, 0, 0, 0], port));\n\n    tracing::info!(\"DBX Web server starting on http://{}\", addr);\n    if public_base_path != \"/\" {\n        tracing::info!(\"Serving DBX Web under context path {}\", public_base_path);\n    }\n    if password_disabled {\n        tracing::info!(\"Password protection is disabled\");\n    } else if std::env::var(\"DBX_PASSWORD\").is_ok() {","sourceCodeStart":1085,"sourceCodeEnd":1121,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/crates/dbx-web/src/main.rs#L1085-L1121","documentation":"During router construction, dbx-web calls web_mcp_router(&web_state) and expects the MCP configuration to be valid. An Err here means the Model Context Protocol router could not be built from the current state/config, so startup panics.","triggerScenarios":"web_mcp_router(&web_state) returns Err because MCP settings (env-derived config, AI/dialect plugin state, or route registration) are inconsistent — e.g., an invalid MCP config value or a failure assembling the MCP sub-router.","commonSituations":"Misconfigured MCP-related environment variables; an incompatible or broken dialect/plugin loaded from the plugins directory corrupting the state the MCP router depends on; code changes where the MCP router builder now returns Err for a previously accepted config.","solutions":["Review and correct MCP-related environment variables/config feeding web_state.","Check the plugin/dialect directories (data_dir/plugins/dialects) for invalid plugins and remove them, then restart.","Run web_mcp_router with the same state in a test to surface the underlying Err message.","Downgrade/revert to a dbx-web version compatible with your MCP configuration, or update the config to the new format.","Change expect() to log the error and start without the MCP router merged."],"exampleFix":"// before\nif let Some(mcp_router) = web_mcp_router(&web_state).expect(\"Invalid DBX Web MCP configuration\") {\n// after\nmatch web_mcp_router(&web_state) {\n    Ok(Some(mcp_router)) => { app = app.merge(mcp_router); }\n    Ok(None) => {}\n    Err(e) => tracing::error!(\"MCP disabled, invalid configuration: {e}\"),\n}","handlingStrategy":"try-catch","validationCode":"// validate MCP config inputs before building state\nlet mcp_enabled = std::env::var(\"DBX_MCP_ENABLED\").map(|v| v != \"0\").unwrap_or(true);\n// verify plugin dir contains loadable plugins\nlet plugins_ok = std::path::Path::new(&data_dir).join(\"plugins/dialects\")\n    .read_dir().map(|mut d| d.next().is_none() || true).unwrap_or(true);","typeGuard":null,"tryCatchPattern":"match web_mcp_router(&web_state) {\n    Ok(Some(mcp_router)) => { app = app.merge(mcp_router); tracing::info!(\"DBX Web MCP enabled at /mcp\"); }\n    Ok(None) => {}\n    Err(e) => tracing::error!(\"MCP disabled, invalid configuration: {e}\"),\n}","preventionTips":["Validate MCP-related environment variables before deployment.","Remove broken dialect plugins from the plugins directory.","Pin dbx-web versions and read changelogs for MCP config format changes.","Test router construction in CI with your production config."],"tags":["mcp","rust","configuration","startup"],"backgroundTag":"invalid-configuration","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}