Skip to content

Fix NPE in getPlaylistHeader() when browseMetadataResponse is null#1510

Open
dweep-js wants to merge 1 commit into
TeamNewPipe:devfrom
dweep-js:fix/playlist-header-npe-on-continuation
Open

Fix NPE in getPlaylistHeader() when browseMetadataResponse is null#1510
dweep-js wants to merge 1 commit into
TeamNewPipe:devfrom
dweep-js:fix/playlist-header-npe-on-continuation

Conversation

@dweep-js

@dweep-js dweep-js commented Jun 11, 2026

Copy link
Copy Markdown

On playlist continuation pages (getPage()), browseMetadataResponse is not set, causing a NullPointerException when getPlaylistHeader() tries to call .getObject() on it.

Fix by returning an empty JsonObject early when browseMetadataResponse is null, avoiding the crash on subsequent playlist page loads.

Fixes: TeamNewPipe/NewPipe#13593

  • 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.

On playlist continuation pages (getPage()), browseMetadataResponse is
not set, causing a NullPointerException when getPlaylistHeader() tries
to call .getObject() on it.

Fix by returning an empty JsonObject early when browseMetadataResponse
is null, avoiding the crash on subsequent playlist page loads.

Fixes: TeamNewPipe/NewPipe#13593
@sonarqubecloud

Copy link
Copy Markdown

@absurdlylongusername absurdlylongusername left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add regression tests that address this bug fix, so can easily verify that it doesn't work without the fix, and does work with the fix.

This makes it quicker to test changes without having to reproduce it manually in NewPipe

@AudricV AudricV left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for your pull request.

While this fixes the null pointer exception, methods used by getPage of a new YoutubePlaylistExtractor instance relying on browseMetadataResponse to check for something won't work properly (and for other fields used too).

Instead, a proper fix would be to propagate in the page IDs the needed data like done in YoutubeChannelTabExtractor. In this case, only the result of isCoursePlaylist needs to be saved.

So you should:

  • remove the isCoursePlaylist field
  • add a isCoursePlaylist boolean parameter to collectStreamsFrom method
  • use the extraction code currently in the isCoursePlaylist method as the value of this new boolean parameter in the getInitialPage method
  • add a page ID to Page objects built by getNextPageFrom, by passing the isCoursePlaylist boolean as a string. To do so, use the Page(String, String, List<String>, Map<String, String>, byte[]) constructor with the following (the current url value, null, List.of(isCoursePlaylist), null, body)
  • retrieve the string value in getPage and convert it to a boolean, while handling the lack of the ID by using false in this case. Then pass this boolean value in the collectStreamsFrom call.

If that's too complex for you, that's fine, I wanted to fix this issue, so I can do this in a different PR.

@AudricV AudricV added bug Issue or PR is related to a bug YouTube Service, https://www.youtube.com/ labels Jun 11, 2026
@mufasacubana8-pixel

This comment was marked as spam.

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 YouTube Service, https://www.youtube.com/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[YouTube] Cannot load playlists continuations

4 participants