{"record":{"id":"29a0d3317deb8250","repo":"LykosAI/StabilityMatrix","slug":"civarchive-detail-page-was-missing-model-data","errorCode":null,"errorMessage":"CivArchive detail page was missing model data","messagePattern":"CivArchive detail page was missing model data","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Api/CivArchiveApiClient.cs","lineNumber":201,"sourceCode":"        // at the model's primary version instead of pageProps.model — follow it like the\n        // browser would. Guarded against self-redirects so a server quirk can't loop us.\n        if (\n            pageProps.Model is null\n            && !string.IsNullOrWhiteSpace(pageProps.RedirectUrl)\n            && BuildDetailDataPath(pageProps.RedirectUrl) != nextDataPath\n        )\n        {\n            var redirected = await GetModelDetailsAsync(pageProps.RedirectUrl, cancellationToken);\n            detailsCache.Add(\n                nextDataPath,\n                new CacheEntry<CivArchiveModelDetailsResponse>(DateTimeOffset.UtcNow, redirected)\n            );\n            return redirected;\n        }\n\n        var model =\n            pageProps.Model\n            ?? throw new InvalidOperationException(\"CivArchive detail page was missing model data\");\n\n        // The API returns version, platform, and platform_name as siblings of model\n        // under pageProps, so merge them into the model object\n        if (pageProps.Version is not null)\n        {\n            model.Version = pageProps.Version;\n        }\n\n        model.Platform ??= pageProps.Platform;\n        model.PlatformName ??= pageProps.PlatformName;\n\n        var detailsResult = new CivArchiveModelDetailsResponse { Model = model };\n        detailsCache.Add(\n            nextDataPath,\n            new CacheEntry<CivArchiveModelDetailsResponse>(DateTimeOffset.UtcNow, detailsResult)\n        );\n        return detailsResult;\n    }","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Api/CivArchiveApiClient.cs#L183-L219","documentation":"GetModelDetailsAsync throws InvalidOperationException when pageProps exists but pageProps.Model is null — the detail page data loaded but carries no model object. This happens after redirect handling when the final payload still lacks the model.","triggerScenarios":"Calling GetModelDetailsAsync for a model whose page renders but whose __NEXT_DATA__ has pageProps without a model (e.g. soft-deleted model, suspended content, schema change moving model under a new key).","commonSituations":"Model removed or made unavailable on Civitai/CivArchive, site restructure relocating the model node in pageProps, race between listing data and detail page state.","solutions":["Confirm the model still exists by opening its URL in a browser","Update CivArchiveDetailPageResponse mapping if the model key changed","Treat as entity-not-found and remove/stale-mark the local model","Check the self-redirect guard logic if a redirect loop was involved"],"exampleFix":"// before\nvar model = pageProps.Model ?? throw new InvalidOperationException(\"CivArchive detail page was missing model data\");\n// after\nif (pageProps.Model is null) throw new InvalidOperationException($\"CivArchive model not found: {relativeUrl}\");","handlingStrategy":"fallback","validationCode":"var resp = await GetNextDataAsync<CivArchiveDetailPageResponse>(path, ct);\nbool modelPresent = resp?.PageProps?.Model is not null;","typeGuard":"bool HasModel(CivArchiveDetailPageResponse r) => r?.PageProps?.Model is not null;","tryCatchPattern":"try { return await api.GetModelDetailsAsync(url); }\ncatch (InvalidOperationException) { /* treat as not-found */ return null; }","preventionTips":["Treat null model as entity-not-found in sync logic","Stale-mark local models when detail fetch returns no model","Re-check after CivArchive schema updates","Verify existence in a browser when debugging"],"tags":["scraping","nextjs","api","entity-not-found"],"backgroundTag":"unexpected-response-shape","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}