Skip to content

nightly-c9df7a94-ls288

Pre-release
Pre-release

Choose a tag to compare

@LinuxServer-CI LinuxServer-CI released this 20 May 02:19
· 14 commits to nightly since this release
578b840

CI Report:

https://ci-tests.linuxserver.io/linuxserver/beets/nightly-c9df7a94-ls288/index.html

LinuxServer Changes:

No changes

Remote Changes:

fix(hooks): chain original error when cached_property AttrDict lookup fails (#6558) (#6564)

Fixes #6558.

Problem

When a cached_property on an AttrDict subclass raises
AttributeError during its own computation, Python's attribute lookup
falls back to __getattr__ with the property's own name. That masks the
real missing field behind a misleading traceback like:

AttributeError: 'AlbumInfo' object has no attribute 'raw_data'

…even though raw_data exists on the instance and the code inside
raw_data is what blew up on a missing sibling attribute. Users and
maintainers hit this both on #6558 and on the earlier #6503 / #6506
reports (different metadata providers, same masking shape).

Fix

In AttrDict.__getattr__, if the looked-up class attribute is a
cached_property, invoke it explicitly. If it raises AttributeError,
re-raise as RuntimeError with from exc so the original cause is
preserved on the traceback and names the attribute that actually failed.

Plain missing-attribute behaviour (obj.nope on an AttrDict) is
unchanged — that still raises AttributeError as before.

Tests

Added a regression class TestAttrDictCachedPropertyMasking in
test/autotag/test_hooks.py covering:

  1. real missing attr in a cached_property body surfaces as
    RuntimeError naming the missing field
  2. the RuntimeError.__cause__ is the original AttributeError
  3. a plain missing attr on an AttrDict still raises AttributeError
  4. existing dict-key access (obj.title) still works

Full test/autotag/test_hooks.py suite: 90 passed locally.

Follow-up

Picked approach (1) from @snejus' comment on #6558
(beetbox/beets#6558 (comment)).
Happy to iterate on the exception type or wording.