fix(civitai): anchor model-page URL parsing and improve missing-model diagnostics (#1140)

This commit is contained in:
Eric-Yeh
2026-10-09 08:07:00 +08:00
committed by GitHub
parent fad17decdf
commit 01ffda7303
6 changed files with 71 additions and 8 deletions
+14 -3
View File
@@ -329,8 +329,19 @@ class CivitaiClient:
"name": result.get("name", ""),
}
message = self._extract_error_message(result)
if message and "not found" in message.lower():
raise ResourceNotFoundError(f"Resource not found for model {model_id}")
if message and (
"not found" in message.lower()
or message.lower().startswith("no model with id ")
):
raise ResourceNotFoundError(
f"Civitai model {model_id} was not found. Check the original "
"Civitai link: use the model ID from /models/<id>, not a "
"version ID from ?modelVersionId=<id> or "
"/api/download/models/<id>. If the model ID is correct, "
"the model may have been removed or made inaccessible. "
"If the page opens only when logged in, check the Civitai "
"API key in LoRA Manager settings."
)
if is_expected_offline_error(message):
logger.info("Civitai request skipped: %s", OFFLINE_FRIENDLY_MESSAGE)
return None
@@ -347,7 +358,7 @@ class CivitaiClient:
except RateLimitError:
raise
except ResourceNotFoundError as exc:
logger.info("Model %s is no longer available on Civitai: %s", model_id, exc)
logger.info("Civitai model lookup failed: %s", exc)
raise
except Exception as e:
logger.error("Error fetching model versions: %s", e, exc_info=True)
+2 -1
View File
@@ -148,7 +148,8 @@ def extract_civitai_model_url_parts(
if parsed is None:
return None, None
path_match = re.search(r"/models/(\d+)", parsed.path)
# Download URLs contain version IDs, not model IDs.
path_match = re.match(r"^/models/(\d+)(?:/|$)", parsed.path)
if not path_match:
return None, None