Skip to content

[SoundCloud] Use long integers (64-bit) for track IDs to prevent overflows#1450

Merged
TobiGr merged 4 commits intoTeamNewPipe:devfrom
G-flat:fix_soundcloud_track_id_overflow
Feb 21, 2026
Merged

[SoundCloud] Use long integers (64-bit) for track IDs to prevent overflows#1450
TobiGr merged 4 commits intoTeamNewPipe:devfrom
G-flat:fix_soundcloud_track_id_overflow

Conversation

@G-flat
Copy link
Copy Markdown
Contributor

@G-flat G-flat commented Jan 30, 2026

  • I carefully read the contribution guidelines and agree to them.
  • I have tested the API against NewPipe.
  • I agree to create a pull request for NewPipe as soon as possible to make it compatible with the changed API.

In TeamNewPipe/NewPipe#12584, loading the https://soundcloud.com/roman-bene-939339090/dreams track will lead to an error that says no track with id -2139744901 in response, which comes from SoundcloudPlaylistExtractor.getPage(), as well as an HTTP 404 error from SoundcloudParsingHelper.getStreamsFromApi().

From SoundcloudStreamExtractor.getId(), the track's ID is 2155222395, but in SoundcloudParsingHelper.getStreamsFromApi(), the API URL becomes https://api-v2.soundcloud.com/tracks/-2139744901/related?client_id=<client_id>. This led to the HTTP 404 error because the track ID became -2139744901 instead of 2155222395, which came from using a signed 32-bit track ID that caused 2155222395 (0x8076157b) to overflow to -2139744901 (0x8076157b - 0x100000000).

Similarly, in TeamNewPipe/NewPipe#12822, the track "Farming Life in Another World Elf Girls Song Funk" by Bemax - ビマックス has a track ID of 2174506221 which overflowed to -2120461075, and in TeamNewPipe/NewPipe#12904, "PLUMMET" by Quarters has a track ID of 2214328829 which overflowed to -2080638467.

These issues can be fixed by increasing the bit width for track IDs from 32 bits to 64 bits. This pull request fixes TeamNewPipe/NewPipe#12584, fixes TeamNewPipe/NewPipe#12822 and fixes TeamNewPipe/NewPipe#12904.

@TobiGr TobiGr added bug Issue or PR is related to a bug SoundCloud Service, https://soundcloud.com/ labels Jan 30, 2026
Copy link
Copy Markdown
Contributor

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

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

thank you!

} else {
// %09d would be enough, but a 0 before the number does not create
// problems, so let's be sure
ids.add(String.format("%010d", track.getInt("id")));
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.

This change causes the mocks to be invalid. Please add a test for a very small ID and also for one that is exceeding the 32 bit of an int. You can fix the tests by recording the mocks for all SoundCloud tests again (see our docs for more info).

Copy link
Copy Markdown
Contributor Author

@G-flat G-flat Jan 31, 2026

Choose a reason for hiding this comment

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

I updated the SoundcloudPlaylistExtractor mocks and also added two SoundcloudStreamExtractor tests, one for a small track ID (135535700) and one for a track ID that's larger than 32 bits of an int (2167944333).

@absurdlylongusername absurdlylongusername added the template missing The bug/feature template is missing (e.g. the used app does not support issue templates) label Jan 30, 2026
@AudricV AudricV removed the template missing The bug/feature template is missing (e.g. the used app does not support issue templates) label Feb 6, 2026
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

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

thank you

@TobiGr TobiGr merged commit ba70ea7 into TeamNewPipe:dev Feb 21, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue or PR is related to a bug SoundCloud Service, https://soundcloud.com/

Projects

None yet

4 participants