{"record":{"id":"893f5c761e1eb62d","repo":"LemmyNet/lemmy","slug":"failed-to-construct-site-response-e","errorCode":null,"errorMessage":"Failed to construct site response: {e}","messagePattern":"Failed to construct site response: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/api/api_crud/src/site/read.rs","lineNumber":25,"sourceCode":"  oauth_provider::AdminOAuthProvider,\n  registration_application::RegistrationApplication,\n  tagline::Tagline,\n};\nuse lemmy_db_views_local_user::LocalUserView;\nuse lemmy_db_views_person::PersonView;\nuse lemmy_db_views_site::{SiteView, api::GetSiteResponse};\nuse lemmy_utils::{CacheLock, VERSION, build_cache, error::LemmyResult};\nuse std::sync::LazyLock;\n\npub async fn get_site(\n  local_user_view: Option<LocalUserView>,\n  context: Data<LemmyContext>,\n) -> LemmyResult<Json<GetSiteResponse>> {\n  // This data is independent from the user account so we can cache it across requests\n  static CACHE: CacheLock<GetSiteResponse> = LazyLock::new(build_cache);\n  let mut site_response = Box::pin(CACHE.try_get_with((), read_site(&context)))\n    .await\n    .map_err(|e| anyhow::anyhow!(\"Failed to construct site response: {e}\"))?;\n\n  // filter oauth_providers for public access\n  if !local_user_view\n    .map(|l| l.local_user.admin)\n    .unwrap_or_default()\n  {\n    site_response.admin_oauth_providers = vec![];\n  }\n\n  Ok(Json(site_response))\n}\n\nasync fn read_site(context: &LemmyContext) -> LemmyResult<GetSiteResponse> {\n  let site_view = SiteView::read_local(&mut context.pool()).await?;\n  let admins = PersonView::list_admins(None, site_view.instance.id, &mut context.pool()).await?;\n  let all_languages = Language::read_all(&mut context.pool()).await?;\n  let discussion_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?;\n  let blocked_urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?;","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/LemmyNet/lemmy/blob/439734dd638a2c06a2f907beab7dcf4646e88f86/crates/api/api_crud/src/site/read.rs#L7-L43","documentation":"Context-wrapping error in get_site: building the GetSiteResponse (aggregating site view, admins, oauth providers, taglines, registration application, etc.) failed for an underlying reason `e`. It fires when any database read or mapping needed to assemble the site response returns an error; the message surfaces that cause, it is not itself a distinct failure.","triggerScenarios":"Thrown at crates/api/api_crud/src/site/read.rs:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the chained cause `e` (database connectivity, missing local site row, federation config) and fix the underlying failure.","Verify the local site exists and is configured (SiteView is required to build the response).","Retry the request once the database/backend issue reported in `e` is resolved."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"439734dd638a2c06a2f907beab7dcf4646e88f86","analyzedAt":"2026-09-06T11:28:35.035Z","contentChangedAt":"2026-09-06T11:28:35.035Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}