{"record":{"id":"18c5016c33535c15","repo":"LemmyNet/lemmy","slug":"failed-to-build-url-blocklist-due-to","errorCode":null,"errorMessage":"Failed to build URL blocklist due to `{}`","messagePattern":"Failed to build URL blocklist due to `(.+?)`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/api/api_utils/src/utils.rs","lineNumber":436,"sourceCode":"      .time_to_live(CACHE_DURATION_FEDERATION)\n      .build()\n  });\n\n  Ok(\n    URL_BLOCKLIST\n      .try_get_with::<_, LemmyError>((), async {\n        let urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?;\n\n        // The urls are already validated on saving, so just escape them.\n        // If this regex creation changes it must be synced with\n        // lemmy_utils::utils::markdown::create_url_blocklist_test_regex_set.\n        let regexes = urls.iter().map(|url| format!(r\"\\b{}\\b\", escape(&url.url)));\n\n        let set = RegexSet::new(regexes)?;\n        Ok(set)\n      })\n      .await\n      .map_err(|e| anyhow::anyhow!(\"Failed to build URL blocklist due to `{}`\", e))?,\n  )\n}\n\n// `local_site` is optional so that tests work easily\npub fn check_nsfw_allowed(nsfw: Option<bool>, local_site: Option<&LocalSite>) -> LemmyResult<()> {\n  let is_nsfw = nsfw.unwrap_or_default();\n  let nsfw_disallowed = local_site.is_some_and(|s| s.nsfw_content_disallowed);\n\n  if nsfw_disallowed && is_nsfw {\n    return Err(LemmyErrorType::NsfwNotAllowed.into());\n  }\n\n  Ok(())\n}\n\n/// Read the site for an ap_id.\n///\n/// Used for GetCommunityResponse and GetPersonDetails","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/LemmyNet/lemmy/blob/439734dd638a2c06a2f907beab7dcf4646e88f86/crates/api/api_utils/src/utils.rs#L418-L454","documentation":"Validation error in get_url_blocklist: building the RegexSet from the LocalSiteUrlBlocklist entries failed (RegexSet::new returned an error). It fires when URL blocklist rows cannot be combined into a valid regex set — e.g. unexpected pattern content in a saved blocklist URL; the input at fault is the blocklist URL rows read from the database.","triggerScenarios":"Thrown at crates/api/api_utils/src/utils.rs:436 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Review the local site URL blocklist rows for patterns that break RegexSet compilation and correct or remove them.","Inspect the inner error to identify the offending regex entry.","Re-validate blocklist URLs on save so invalid patterns never reach this builder."],"exampleFix":null,"handlingStrategy":"validation","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"}