Skip to content

Spotify rate limit improvements#21254

Merged
GTFalcao merged 5 commits into
masterfrom
spotify-improvements
Jun 26, 2026
Merged

Spotify rate limit improvements#21254
GTFalcao merged 5 commits into
masterfrom
spotify-improvements

Conversation

@GTFalcao

@GTFalcao GTFalcao commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Reworked the new-track-by-artist trigger so that it no longer fetches tracks for albums that had no change in the number of tracks, on every single run. It still does this once a day as a fallback, in case an album had changes without changing the amount of tracks (rare).

Albums that had the amount of tracks change since the last run always immediately retrieve the tracks.

Also adjusted the app-wide retry logic to use delays of 5-10-15 seconds for the 1st/2nd/3rd retry, respectively (previously it was 0-5-10 seconds, likely due to an oversight)

Summary by CodeRabbit

  • New Features
    • Enhanced artist track updates to more accurately detect changes and refresh listings with less frequent full rescans.
    • Improved album/track fetching by deduplicating album IDs and using more reliable pagination to expand coverage.
  • Bug Fixes
    • Improved handling of Spotify HTTP 429 responses by adjusting retry timing and when requests stop retrying.
  • Chores
    • Bumped Spotify action/source versions (and the Spotify package version) for compatibility and consistent updates.

@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
pipedream-docs-redirect-do-not-edit Ignored Ignored Jun 26, 2026 4:40am

Request Review

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 028d9f2e-e5ea-42cd-bb29-006185a19221

📥 Commits

Reviewing files that changed from the base of the PR and between ecbd2ec and 34450c2.

📒 Files selected for processing (1)
  • components/spotify/spotify.app.mjs

📝 Walkthrough

Walkthrough

Spotify app helpers now change retry behavior, dedupe artist albums, and batch track lookups by album ID. The artist-track action and new-track source use the updated flow, and several action/source manifests plus the Spotify package version are bumped.

Changes

Spotify track retrieval and version bumps

Layer / File(s) Summary
App helpers and retry
components/spotify/spotify.app.mjs
The Spotify app retry cutoff changes, getArtistAlbums paginates and deduplicates album listings, and getAllTracksByAlbumIds deduplicates album IDs before flattening track items.
Artist tracks action update
components/spotify/actions/get-all-tracks-by-artist/get-all-tracks-by-artist.mjs
The action run now loads artist albums first and then fetches tracks by the returned album IDs.
Source stale-album recheck
components/spotify/sources/new-track-by-artist/new-track-by-artist.mjs
The source adds a 24-hour recheck interval, bumps its version, reads and persists lastCheckedAt and albumTrackCounts, selects stale albums by interval or track-count mismatch, and emits track events for fetched albums.
Action version metadata
components/spotify/actions/*/*.mjs
The Spotify action manifests increment their exported version fields, including get-all-tracks-by-artist.
Component version metadata
components/spotify/package.json, components/spotify/sources/new-playlist/new-playlist.mjs, components/spotify/sources/new-saved-track/new-saved-track.mjs, components/spotify/sources/new-track-in-playlist/new-track-in-playlist.mjs
The Spotify package manifest and remaining source manifests increment their exported version fields.

Sequence Diagram(s)

get-all-tracks-by-artist flow

sequenceDiagram
  participant GetAllTracksByArtist as "get-all-tracks-by-artist"
  participant SpotifyApp as "spotify.app.mjs"
  participant SpotifyAPI as "Spotify API"

  GetAllTracksByArtist->>SpotifyApp: getArtistAlbums(artistId, market)
  SpotifyApp->>SpotifyAPI: request artist albums
  SpotifyApp-->>GetAllTracksByArtist: albums
  GetAllTracksByArtist->>SpotifyApp: getAllTracksByAlbumIds(albums.map((album) => album.id), market)
  SpotifyApp->>SpotifyAPI: request album tracks
  SpotifyApp-->>GetAllTracksByArtist: tracks
Loading

new-track-by-artist recheck flow

sequenceDiagram
  participant NewTrackByArtist as "new-track-by-artist"
  participant DB as "this.db"
  participant SpotifyApp as "spotify.app.mjs"
  participant SpotifyAPI as "Spotify API"

  NewTrackByArtist->>DB: read lastCheckedAt and albumTrackCounts
  NewTrackByArtist->>NewTrackByArtist: compute dueForFullSweep and staleAlbumIds
  NewTrackByArtist->>SpotifyApp: getArtistAlbums(artistId, market)
  SpotifyApp->>SpotifyAPI: request artist albums
  SpotifyApp-->>NewTrackByArtist: albums
  NewTrackByArtist->>SpotifyApp: getAllTracksByAlbumIds(staleAlbumIds, market)
  SpotifyApp->>SpotifyAPI: request album tracks
  SpotifyApp-->>NewTrackByArtist: tracks
  NewTrackByArtist->>NewTrackByArtist: emit track event per track
  NewTrackByArtist->>DB: store albumTrackCounts and lastCheckedAt
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

prioritized

Possibly related PRs

Suggested reviewers

  • michelle0927
  • mariano-pd
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description has a summary but omits the required checklist sections for versioning, app integration, and CodeRabbit review. Add the full Checklist section and explicitly confirm version bumps, app integration status, and acknowledgment of CodeRabbit review comments.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main theme of the PR: Spotify rate-limit and trigger efficiency improvements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch spotify-improvements

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@components/spotify/sources/new-track-by-artist/new-track-by-artist.mjs`:
- Line 15: Update the component metadata in new-track-by-artist.mjs so the
description follows the required agent-friendly source-description structure and
ends with the exact documentation link format `[See the
documentation](https://...)`. Replace the current trailing `[see docs
here](...)` text in the description field, and make sure the final description
is more informative for agents while keeping the required link at the end.
- Around line 54-55: The new-track-by-artist source is accessing persisted state
from run() directly through this.db, which should be hidden behind private state
helpers. Move the lastCheckedAt and albumTrackCounts reads/writes in
NewTrackByArtistSource into private _get...() / _set...() methods, and update
run() and any related handlers to use those helpers so state access follows the
source convention.

In `@components/spotify/spotify.app.mjs`:
- Around line 444-456: The getAllTracksByAlbumIds flow only reads the first page
from each album returned by the /albums request, so tracks beyond that page are
lost. Update the album-track aggregation logic in getAllTracksByAlbumIds to
paginate each album’s tracks using the album tracks endpoint before pushing into
tracks, ensuring all pages are fetched before flattening. Keep the fix localized
around the existing /albums fetch and album.tracks.items handling so the
downstream Get All Tracks by Artist and New Track by Artist paths receive
complete results.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 60b21178-205a-4455-82a4-f73af61a46a2

📥 Commits

Reviewing files that changed from the base of the PR and between 25679dc and 4d433d3.

📒 Files selected for processing (26)
  • components/spotify/actions/add-items-to-playlist/add-items-to-playlist.mjs
  • components/spotify/actions/create-playlist/create-playlist.mjs
  • components/spotify/actions/get-album-tracks/get-album-tracks.mjs
  • components/spotify/actions/get-all-tracks-by-artist/get-all-tracks-by-artist.mjs
  • components/spotify/actions/get-artist-top-tracks/get-artist-top-tracks.mjs
  • components/spotify/actions/get-audio-features-for-a-track/get-audio-features-for-a-track.mjs
  • components/spotify/actions/get-categorys-playlist/get-categorys-playlist.mjs
  • components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs
  • components/spotify/actions/get-playlist-items/get-playlist-items.mjs
  • components/spotify/actions/get-playlist/get-playlist.mjs
  • components/spotify/actions/get-recommendations/get-recommendations.mjs
  • components/spotify/actions/get-track/get-track.mjs
  • components/spotify/actions/list-category-id-options/list-category-id-options.mjs
  • components/spotify/actions/list-genres-options/list-genres-options.mjs
  • components/spotify/actions/list-playlist-id-options/list-playlist-id-options.mjs
  • components/spotify/actions/list-saved-user-tracks-id-options/list-saved-user-tracks-id-options.mjs
  • components/spotify/actions/remove-items-from-playlist/remove-items-from-playlist.mjs
  • components/spotify/actions/remove-user-saved-tracks/remove-user-saved-tracks.mjs
  • components/spotify/actions/save-track/save-track.mjs
  • components/spotify/actions/search/search.mjs
  • components/spotify/package.json
  • components/spotify/sources/new-playlist/new-playlist.mjs
  • components/spotify/sources/new-saved-track/new-saved-track.mjs
  • components/spotify/sources/new-track-by-artist/new-track-by-artist.mjs
  • components/spotify/sources/new-track-in-playlist/new-track-in-playlist.mjs
  • components/spotify/spotify.app.mjs

Comment thread components/spotify/sources/new-track-by-artist/new-track-by-artist.mjs Outdated
Comment thread components/spotify/sources/new-track-by-artist/new-track-by-artist.mjs Outdated
Comment thread components/spotify/spotify.app.mjs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@components/spotify/spotify.app.mjs`:
- Around line 454-462: Guard the album iteration in spotify.app.mjs so null
placeholders from data.albums are skipped before calling getAlbumTracks().
Update the loop in the album-tracks fetch logic to check each album entry and
continue past null/undefined values, preserving the rest of the tracks
collection even when one album is unavailable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2e3a88e9-8dd4-487e-94dc-8fa0c759a6db

📥 Commits

Reviewing files that changed from the base of the PR and between 4d433d3 and ecbd2ec.

📒 Files selected for processing (2)
  • components/spotify/sources/new-track-by-artist/new-track-by-artist.mjs
  • components/spotify/spotify.app.mjs

Comment thread components/spotify/spotify.app.mjs

@michelle0927 michelle0927 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! Ready for QA.

@michelle0927 michelle0927 moved this from Ready for PR Review to Ready for QA in Component (Source and Action) Backlog Jun 26, 2026
@GTFalcao GTFalcao merged commit cd2d97a into master Jun 26, 2026
9 checks passed
@GTFalcao GTFalcao deleted the spotify-improvements branch June 26, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants