Repository navigation
Fix CivitAI model browser failing when an image has null width or height - #1793
Open
deepratna-awale wants to merge 1 commit into
Open
deepratna-awale wants to merge 1 commit into
deepratna-awale wants to merge 1 commit into
Conversation
CivitAI returns null width/height for some images, which made the whole /api/v1/models page fail to deserialize. Make CivitImage.Width/Height nullable and default to 0 where they are mapped to OpenArt thumbnails. Fixes LykosAI#1792
|
CLA Assistant Lite bot CLA Assistant bot All Contributors have signed the CLA. |
Author
|
I have read the CLA Document and I hereby sign the CLA |
deepratna-awale
marked this pull request as ready for review
November 6, 2026 09:28
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1792
Problem
CivitAI sometimes returns
"width": null, "height": nullfor model preview images.CivitImage.WidthandHeightwere non-nullableint, so/api/v1/modelsfailed to deserialize. The Model Browser then showed "CivitAI can't be reached right now (OK: OK)" and dropped the whole page, so infinite scroll stopped.Reproduced on 2026-11-06 with live data: Illustrious and NoobAI, sorted Newest over a Week, NSFW on. Five models (3032697, 3032929, 3032961, 3032970, 3032979) had ordinary
imageentries with null dimensions. Requesting them through the app'sICivitApiRefit client, with the app's JSON options, threw the sameJsonException ... Path: $.items[0].modelVersions[0].images[0].widthas the issue.Changes
CivitImage.WidthandHeightare nowint?, following the 2.16.2 fix for null stats.DownloadCivitWorkflowStepuses?? 0where it maps these values ontoOpenArtThumbnail. This is the only consumer.CivitImageTests, which deserializes an image with null dimensions and a models response where one item has them.Impact of
int→int?CivitImage.Width/Heightis the OpenArt thumbnail mapping inDownloadCivitWorkflowStep, which now falls back to0. Downstream, those thumbnails only use the URL. The otherCivitImageuses only touchUrl,TypeandNsfwLevel, and no XAML binds to these fields..cm-info.jsondoesn't store images. The Model Browser's LiteDB cache does. I checked a downgrade against LiteDB 5.0.21: anullwritten by this build reads back as0in a build where the field isint, so nothing crashes. Saved OpenArt workflow metadata still writes a plainint.CivitModelVersionResponse, used by the by-hash lookup for metadata and model import, sharesCivitImage, so it no longer fails on the same nulls.intand usedNullToDefaultJsonConverter<int>. That would also work and would be consistent with it, but it turns "unknown" into0. I choseint?to keep the null. Happy to switch to the converter if you'd rather match the stats fix; it's a two-line change.Testing
dotnet build StabilityMatrix.Avalonia -r osx-arm64builds with 0 errors.The new tests pass, along with the existing JSON converter tests.
On the full suite, 772 tests pass. The 2 failures are
LinkSafeFileSystemTests.GetRealPath_*, and they fail the same way on unmodifiedmainon macOS because the temp dir resolves to/private/var.The live API request for the affected models now returns all 5 items.
Headless UI check of the CivitAI Model Browser against the live API, searching "Gwenc League of Legends" (Model Type: All), with a clean cache for each build: