Skip to content

fix: flexible bundle regex, correct error messages, remove duplicate definition#327

Open
maksimtech wants to merge 1 commit intovitiko98:masterfrom
maksimtech:fix/bundle-regex-and-error-handling
Open

fix: flexible bundle regex, correct error messages, remove duplicate definition#327
maksimtech wants to merge 1 commit intovitiko98:masterfrom
maksimtech:fix/bundle-regex-and-error-handling

Conversation

@maksimtech
Copy link
Copy Markdown

Problem

Bundle.__init__ fails silently when Qobuz ships a bundle whose version suffix doesn't match the hardcoded pattern, then raises a completely misleading error that hides the real cause.

Root cause — overly strict _BUNDLE_URL_REGEX

# Before
r'<script src="(/resources/\d+\.\d+\.\d+-[a-z]\d{3}/bundle\.js)"></script>'
#                                              ^^^^^^
#                               Requires EXACTLY 3 digits after the letter
#                               e.g. -b019 ✓  but -b1234 ✗  -a12 ✗

If the suffix format ever changes (e.g. 8.2.0-b1234), the regex returns no match and the code raises:

NotImplementedError: Bundle URL found   # ← says "found" when it was NOT found

This misleading message makes the failure almost impossible to diagnose.

Changes

File What changed
bundle.py [a-z]\d{3}[a-z]\d+ in _BUNDLE_URL_REGEX (one-or-more digits)
bundle.py \d{9}\d+ and \w{32}\w+ in _APP_ID_REGEX (flexible length)
bundle.py NotImplementedError("Bundle URL found")ValueError("Bundle URL not found")
bundle.py Removed duplicate _BUNDLE_URL_REGEX definition (was defined twice, lines 20–22 and 25–27)

Verification

Tested against the live bundle (/resources/8.1.0-b019/bundle.js) — all three patterns match correctly and get_secrets() returns valid decoded secrets.

App ID : 798273057
Secrets: 3 valid MD5 secrets extracted for abidjan / london / berlin

🤖 Generated with Claude Code

Copy link
Copy Markdown

@mzilinski mzilinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review PR #327

Gutes, fokussiertes Fix — alle vier Änderungen sind sinnvoll und korrekt. Hier mein Feedback:

✅ Positiv

  • Flexible Regex: \d+ statt \d{3} / \d{9} / \w{32} — macht das Matching robuster gegen zukünftige Formatänderungen bei Qobuz. Guter defensiver Ansatz.
  • Fehlermeldung korrigiert: NotImplementedError("Bundle URL found") war offensichtlich falsch (Nachricht sagte "found" obwohl "not found" gemeint war). ValueError("Bundle URL not found") ist sowohl semantisch korrekt als auch der richtige Exception-Typ.
  • Doppelte Definition entfernt: _BUNDLE_URL_REGEX war doppelt definiert (Zeilen 20-22 und 25-27). Die zweite hat die erste still überschrieben — gut, dass das aufgeräumt wurde.

💬 Anmerkung

  • Zeile 53 hat noch eine ähnliche NotImplementedError("Failed to match APP ID") — könnte man ebenfalls zu ValueError ändern, da NotImplementedError eigentlich für abstrakte Methoden gedacht ist. Das ist aber out-of-scope für diesen PR.

Fazit

Sauber, minimal, korrekt. 👍

@maksimtech
Copy link
Copy Markdown
Author

maksimtech commented Mar 31, 2026

Thank you for the thorough review!
Noted on line 53 — I'll address
NotImplementedError → ValueError
in a separate PR.

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.

2 participants