Skip to content

fix: initialize lazy storage before hashing its class - #676

Open
jihtsan wants to merge 1 commit into
SmileyChris:masterfrom
jihtsan:codex/674-lazy-storage-hash
Open

jihtsan wants to merge 1 commit into
SmileyChris:masterfrom
jihtsan:codex/674-lazy-storage-hash

Conversation

@jihtsan

@jihtsan jihtsan commented Oct 18, 2026

Copy link
Copy Markdown

Fixes #674.

Use Django's empty sentinel, as identified in the issue report, to initialize a LazyObject before computing the storage class hash. This makes an untouched lazy storage agree with its initialized/eager equivalent, so Source and Thumbnail manager lookups use the same key before and after initialization.

Add direct regressions for initialization exactly once, fresh Django DefaultStorage, initialized objects and class-path strings, plus actual Source/Thumbnail database round trips. Four new cases fail on the original implementation; the focused suite passes after the correction.

Validation on macOS:

  • Focused tests: 8 passed.
  • Python 3.9.6 / Django 4.2.30 / Pillow 11.3.0, core dependencies: 130 passed, 4 SVG tests skipped.
  • Python 3.14.6 / Django 5.2.18 / Pillow 13.0.0, core dependencies: 130 passed, 4 SVG tests skipped.
  • Python 3.9.6 with SVG extras (svglib 2.3.0 / reportlab 5.0.1): 133 passed, 1 failure. The identical ThumbnailSVGImage.testTag dimensions failure (180×135 rather than 240×180) occurs on a separate clean base checkout (128 passed, 1 failure). This existing optional-renderer failure is outside this patch.
  • Independent probes on both environments confirm eager/lazy lookups in both directions, real Thumbnailer/FieldFile cache retrieval and deletion, custom/nested lazy wrappers and stable class-path hashes.
  • git diff --check passes.

The affected path is LazyObject input to get_storage_hash; the current thumbnail_default_storage implementation generally returns an eager backend. Previously stored records under the sentinel hash may still require cache regeneration. Linux/Windows and the remaining Python/Django matrix were not run locally.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_storage_hash() tests _wrapped is None, but Django's LazyObject sentinel is empty

1 participant