{"record":{"id":"893bd5e74f54a9f2","repo":"LemmyNet/lemmy","slug":"failed-to-construct-regex-e","errorCode":null,"errorMessage":"Failed to construct regex: {e}","messagePattern":"Failed to construct regex: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/api/api_utils/src/utils.rs","lineNumber":410,"sourceCode":"}\n\npub async fn slur_regex(context: &LemmyContext) -> LemmyResult<Regex> {\n  static CACHE: CacheLock<Regex> = LazyLock::new(|| {\n    Cache::builder()\n      .max_capacity(1)\n      .time_to_live(CACHE_DURATION_FEDERATION)\n      .build()\n  });\n  Ok(\n    Box::pin(CACHE.try_get_with((), async {\n      let local_site = SiteView::read_local(&mut context.pool())\n        .await\n        .ok()\n        .map(|s| s.local_site);\n      build_and_check_regex(local_site.and_then(|s| s.slur_filter_regex).as_deref())\n    }))\n    .await\n    .map_err(|e| anyhow::anyhow!(\"Failed to construct regex: {e}\"))?,\n  )\n}\n\npub async fn get_url_blocklist(context: &LemmyContext) -> LemmyResult<RegexSet> {\n  static URL_BLOCKLIST: CacheLock<RegexSet> = LazyLock::new(|| {\n    Cache::builder()\n      .max_capacity(1)\n      .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","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/LemmyNet/lemmy/blob/439734dd638a2c06a2f907beab7dcf4646e88f86/crates/api/api_utils/src/utils.rs#L392-L428","documentation":"Validation error in slur_regex: compiling the slur-filter Regex (built from the local site's slur_filter_regex setting) failed, or the cached build failed. It fires when the admin-configured regex in local_site.slur_filter_regex is invalid, or when try_get_with propagates a concurrent-build failure; the input at fault is the site's slur_filter_regex value.","triggerScenarios":"Thrown at crates/api/api_utils/src/utils.rs:410 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the local site's slur_filter_regex setting and correct invalid regex syntax.","Inspect the wrapped cause `e` to distinguish an invalid regex from a cache/concurrency failure.","Clear or wait out the cache TTL after fixing the regex so a good value is rebuilt."],"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-14T00:17:10.932Z"}