Skip to content

fix(spotify): Ignore a malformed artist ID in the spotlight lookup - #282

Merged
pterw merged 1 commit into
mainfrom
fix/spotify-artist-id
Oct 31, 2026
Merged

pterw merged 1 commit into
mainfrom
fix/spotify-artist-id

Conversation

@pterw

@pterw pterw commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Summary

Closes F-B23-33. /api/artist_spotlight passed a request's artist_id unchecked into https://api.spotify.com/v1/artists/{artist_id}, so a value with / or ../ segments made the server call other Spotify GET routes under the app's token. _request_spotlight_artist in scrobblescope/spotify.py now takes the by-ID path only for a well-formed Spotify ID (exactly 22 ASCII base-62 characters, fullmatch); anything else is treated like an unsuccessful by-ID lookup, so the existing name fallback runs, or the route answers with its decorative fallback when no name is given. The check lives in the Spotify module (global rule 4); the route is unchanged.

One parametrized test in tests/services/test_spotify_service.py asserts on the URLs requested: malformed IDs never reach the artists URL, a well-formed one does. It was red against the unchanged code. Three existing by-ID tests now use a well-formed ID, because their short IDs are malformed under the new rule; their intent is unchanged.

A side task outside the UI audit Minors PR: the patch was written by an outside agent from a written brief, independently reviewed (approved; probes included encoded slashes, non-ASCII digits, fullwidth letters and trailing newlines), then landed with the usual bookkeeping. F-B23-33 is resolved and rotated to the findings archive.

Validation at this head

Head 99690943. Gates: suite-docsync 702 passed, suite-subdirs 1506 passed, suite-core 905 passed (3113 in all), pre-commit (all hooks) and docsync-check pass. One suite-core run hit an unrelated intermittent failure (test_importing_the_app_runs_no_shell_command saw a ver subprocess, which Python's Windows version lookup can spawn under load); the isolated re-run passed and the flake is recorded for the findings triage. No browser gate applies (no template, static or gate change). CI: pending.

Checklist

  • pytest -q passes (update SESSION_CONTEXT Section 1 if test count changed)
  • pre-commit run --all-files passes (all hooks)
  • python scripts/doc_state_sync.py --check exits 0
  • PLAYBOOK Section 3 reflects current WP/task state
  • PLAYBOOK Section 4 has a dated log entry:
    - Batch WP: inside DOCSYNC:CURRENT-BATCH-START/END markers
    - Side task: after DOCSYNC:CURRENT-BATCH-END marker
  • Changes are within scope of the active batch definition
    (or deviation is logged in the Section 4 entry)

The artist spotlight spliced its artist_id straight into the Spotify
artists URL, so a value with "/" or ".." could make the server call
another GET route under the app's token. A by-ID lookup now needs a
22-character base-62 ID; anything else is treated as a failed by-ID
lookup and falls back to the name search. Closes F-B23-33.

An outside agent wrote the patch; an independent review approved it.
Three existing by-ID tests now pass a well-formed ID.

Validation: `pytest -q` -- **3113 passed**.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@pterw
pterw marked this pull request as ready for review October 31, 2026 06:46
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-31T06:46:59.647891Z
We couldn’t complete this review. Comment @codex review to try again.
9969094 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@pterw
pterw merged commit 708fb48 into main Oct 31, 2026
3 checks passed

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Graphify reviewed this change.

No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.

Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 not verified).

Formal verification. PR-changed functions: 0/1 verified (0 proven, 0 may-equivalent, 0 distinguished) · 1 not verified (1 vacuous).

Not verified on this run: \_request\_spotlight\_artist (vacuous: never exercised).


Graphify review — findings

Fixes F-B23-33 by making the artist spotlight lookup take the by-ID path only when the ID is a well-formed Spotify ID (22 base-62 characters), so a value with / or .. can no longer be spliced into the artists URL and reach another GET route under the app's token. A malformed ID is treated like any failed by-ID lookup: no request to the artists URL, then the existing name fallback, or None without a name. Adds a parametrized test for malformed and well-formed IDs, updates three existing spotlight tests to use a valid ID, and bumps the pinned test count to 3113 with the findings, playbook and archive docs updated to match.

No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 452 functions depend on the 326 functions this change touches.

Health — grade B; 10 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):

  • _fetch_and_process() — 25 callers, 10 callees (high)
  • process_albums() — 23 callers, 7 callees (high)
  • search_for_spotify_album_id() — 22 callers, 7 callees (high)
  • fetch_spotify_album_details_batch() — 14 callers, 8 callees (high)
  • _fetch_spotify_misses() — 12 callers, 9 callees (high)
  • background_task() — 15 callers, 5 callees (high)
  • _run_album_job() — 16 callers, 4 callees (high)
  • _process_filtered_albums() — 6 callers, 8 callees (high)
  • …and 2 more

Verification — 452 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 430 function(s) in the blast radius were not formally verified this run

Formal verification

Could not verify: Could not verify \_request\_spotlight\_artist.

The verifier did not have enough to check \_request\_spotlight\_artist, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: not verifiable: all 101 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous

pterw added a commit that referenced this pull request Oct 31, 2026
Take the F-B23-33 fix and its bookkeeping into the UI audit Minors
branch (owner ruling: a merge commit, not a rebase). Only PLAYBOOK and
the log archive conflicted; both sides' history is kept, with PR #282
recorded as merged.

Validation: `pytest -q` -- **3118 passed**.
@pterw pterw mentioned this pull request Oct 31, 2026
6 tasks done
@pterw
pterw deleted the fix/spotify-artist-id branch October 31, 2026 20:10
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.

1 participant