LemmyNet/lemmy · error
Failed to construct site response: {e}
Error message
Failed to construct site response: {e} What it means
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.
Source
Thrown at crates/api/api_crud/src/site/read.rs:25
oauth_provider::AdminOAuthProvider,
registration_application::RegistrationApplication,
tagline::Tagline,
};
use lemmy_db_views_local_user::LocalUserView;
use lemmy_db_views_person::PersonView;
use lemmy_db_views_site::{SiteView, api::GetSiteResponse};
use lemmy_utils::{CacheLock, VERSION, build_cache, error::LemmyResult};
use std::sync::LazyLock;
pub async fn get_site(
local_user_view: Option<LocalUserView>,
context: Data<LemmyContext>,
) -> LemmyResult<Json<GetSiteResponse>> {
// This data is independent from the user account so we can cache it across requests
static CACHE: CacheLock<GetSiteResponse> = LazyLock::new(build_cache);
let mut site_response = Box::pin(CACHE.try_get_with((), read_site(&context)))
.await
.map_err(|e| anyhow::anyhow!("Failed to construct site response: {e}"))?;
// filter oauth_providers for public access
if !local_user_view
.map(|l| l.local_user.admin)
.unwrap_or_default()
{
site_response.admin_oauth_providers = vec![];
}
Ok(Json(site_response))
}
async fn read_site(context: &LemmyContext) -> LemmyResult<GetSiteResponse> {
let site_view = SiteView::read_local(&mut context.pool()).await?;
let admins = PersonView::list_admins(None, site_view.instance.id, &mut context.pool()).await?;
let all_languages = Language::read_all(&mut context.pool()).await?;
let discussion_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?;
let blocked_urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?;View on GitHub (pinned to 439734dd63)
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.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at crates/api/api_crud/src/site/read.rs:25 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of LemmyNet/lemmy@439734dd63 (2026-09-06).
Data as JSON: /api/errors/893f5c761e1eb62d.
Report an issue: GitHub.