Skip to content

Conversation

Fijxu
Copy link
Member

@Fijxu Fijxu commented Apr 10, 2025

Closes #103 and #151

The second commit will contain fixes and new errors that are not directly related to #103, so if it's possible, don't squash this PR, otherwise, I can create a new PR after this gets merged

@Fijxu Fijxu force-pushed the track-unknown-innertube-errors branch 2 times, most recently from 36d1473 to e030ebb Compare April 10, 2025 05:55
@Fijxu Fijxu marked this pull request as ready for review April 10, 2025 06:19
@Fijxu Fijxu force-pushed the track-unknown-innertube-errors branch from feb0bb0 to c5b1ccc Compare April 14, 2025 05:26
@Fijxu
Copy link
Member Author

Fijxu commented Apr 18, 2025

Note to self:

  • Add metrics to count 403 errors returned by the /videoplayback endpoint.
  • Add LIVE_STREAM_OFFLINE status to the ignore list.
  • Add Premieres in * and This live event will begin in * to the reason ignore list.

@Fijxu Fijxu force-pushed the track-unknown-innertube-errors branch from 352fecb to fb92354 Compare April 21, 2025 20:58
@Fijxu
Copy link
Member Author

Fijxu commented Apr 21, 2025

I'll leave it as a draft for now since I plan to refactor some things and I still need to add some metrics

@Fijxu Fijxu marked this pull request as draft April 21, 2025 21:11
Comment on lines 124 to 131
if (googlevideoResponse.status == 403) {
metrics?.videoplaybackForbidden.labels({
method: "HEAD",
}).inc();
}
Copy link
Member Author

Choose a reason for hiding this comment

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

we could track all status codes, but seems overkill to me. I've personally never seen any other http status code more than 403 when the request to /videoplayback fails for any reason

@Fijxu
Copy link
Member Author

Fijxu commented Apr 25, 2025

We can't track Video unavailable errors because Youtube.JS throws an error when the status is ERROR, which includes reasons like Video unavailable and subreasons like This video is no longer available because the YouTube account associated with this video has been terminated. or subreasons related to videos that have been deleted by copyright claims.

https://github.com/LuanRT/YouTube.js/blob/92b8623374a126d60604a54fa4be67b460ddc5e3/src/core/mixins/MediaInfo.ts#L58-L59:

    if (info.playability_status?.status === 'ERROR')
      throw new InnertubeError('This video is unavailable', info.playability_status);

We would need to catch that error somehow in:

const video = new YT.VideoInfo(
[youtubePlayerResponse],
innertubeClient.actions,
generateRandomString(16),
);

Or maybe override the MediaInfo class of https://github.com/LuanRT/YouTube.js/blob/92b8623374a126d60604a54fa4be67b460ddc5e3/src/core/mixins/MediaInfo.ts#L33C1-L33C33 so we can handle the ERROR status ourselves. Maybe there is better way tho.

@Fijxu
Copy link
Member Author

Fijxu commented Apr 25, 2025

Note to self:

@Fijxu Fijxu force-pushed the track-unknown-innertube-errors branch from bad177b to b1eb0b2 Compare May 1, 2025 23:25
@Fijxu
Copy link
Member Author

Fijxu commented May 1, 2025

Now it should track Video unavailable errors as per #103 and URL deciphering errors. I'll leave it running on my instances of invidious-companion to add more subReasons that can appear on some Video unavailable reason.

@Fijxu Fijxu force-pushed the track-unknown-innertube-errors branch 3 times, most recently from 8f1ebe1 to 32b1286 Compare May 3, 2025 01:24
@Fijxu
Copy link
Member Author

Fijxu commented May 3, 2025

We should filter the errors by the client used? Because since we switched to MWEB and TV, I got a lot of unknown reaons and subreasons like: This video is private, instead of the one that the WEB client returned which was Private video

For example, WEB returns this on a private video:

{
  "playabilityStatus": {
    "status": "LOGIN_REQUIRED",
    "messages": [
      "This is a private video. Please sign in to verify that you may see it."
    ],
    "errorScreen": {
      "playerErrorMessageRenderer": {
        "subreason": {
          "simpleText": "Sign in if you've been granted access to this video"
        },
        "reason": {
          "simpleText": "Private video" // <- the reason we are catching
        },
        ...

meanwhile MWEB returns:

{
  "playabilityStatus": {
    "status": "LOGIN_REQUIRED",
    "reason": "This video is private", 
    "messages": [
      "This is a private video. Please sign in to verify that you may see it."
    ],
    "errorScreen": {
      "playerErrorMessageRenderer": {
        "subreason": {
          "runs": [
            {
              "text": "If the owner of this video has granted you access, please "
            },
            ...

Meanwhile, I'm going to adapt it so it can search for the reason on every JSON object, without client filtering. In my opinion, having a label or some way to display which client was used to display the unknown error would be better.

@Fijxu Fijxu force-pushed the track-unknown-innertube-errors branch 3 times, most recently from 85ea2c1 to 94a07f5 Compare May 3, 2025 03:54
@Fijxu Fijxu force-pushed the track-unknown-innertube-errors branch from d109734 to 1daa09e Compare May 17, 2025 23:44
@unixfox
Copy link
Member

unixfox commented May 18, 2025

@Fijxu the fallback clients shouldn't be tried if there are no streamingData returned, that's what a private video do. There are no streams URLs returned since it's a private video.

https://github.com/iv-org/invidious-companion/blob/master/src/lib/helpers/youtubePlayerReq.ts#L58-L65

Or maybe my algorithm is wrong. On those cases, only WEB should be tried.

@Fijxu
Copy link
Member Author

Fijxu commented May 18, 2025

the fallback clients shouldn't be tried if there are no streamingData returned

You're right 😅 I did that because I didn't even read 16d06cd at the time you pushed it.

When I was adding those type of errors, I used ClientType.MWEB in Innertube.create on my Invidious companion fork, and then I got that chunk of errors that are valid for MWEB, but didn't used to appear on WEB.

I'll delete those that I added because of MWEB, but some are still valid for the WEB too

@Fijxu Fijxu force-pushed the track-unknown-innertube-errors branch 2 times, most recently from 2411ef7 to 299765b Compare June 30, 2025 21:49
@Fijxu Fijxu marked this pull request as ready for review June 30, 2025 21:52
@Fijxu Fijxu force-pushed the track-unknown-innertube-errors branch from 9c003ae to d6d6c25 Compare June 30, 2025 21:57
@Fijxu Fijxu linked an issue Jun 30, 2025 that may be closed by this pull request
@Fijxu
Copy link
Member Author

Fijxu commented Jun 30, 2025

I consider this ready to merge. It has been working pretty well from my testing. My metrics are public so here is how they look like:

https://metrics.nadeko.net/d/1-0-0/invidious-companion?orgId=2&from=now-7d&to=now&timezone=browser&refresh=5s

@unixfox unixfox force-pushed the master branch 2 times, most recently from 6967726 to f8296a5 Compare September 3, 2025 14:14
@unixfox unixfox requested a review from Copilot September 3, 2025 15:21
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements metrics tracking for unidentified InnerTube errors to improve monitoring and debugging capabilities. The changes expand error categorization and add tracking for video playback failures and player deciphering errors.

  • Enhanced metrics system to support labeled counters for better error categorization
  • Added comprehensive error tracking for InnerTube responses including status, reason, and subreason classification
  • Implemented tracking for video playback 403 errors and YouTube.js player deciphering failures

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/routes/videoPlaybackProxy.ts Adds metrics tracking for 403 forbidden responses from YouTube's videoplayback endpoint
src/lib/helpers/youtubePlayerHandling.ts Implements error tracking for player deciphering failures with try-catch wrapper
src/lib/helpers/metrics.ts Major refactoring to support labeled metrics and comprehensive InnerTube error categorization
grafana_dashboard.json Updates dashboard configuration to display new metrics with improved visualization

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Added reason and subreason for sentitive content videos ("CONTENT_CHECK_REQUIRED")

fix: fix typo: `SignInToConfirmBot` -> `signInToConfirmBot`
Some subreaons of video unavailable may be missing, those will be added
in subsequent commits.
@Fijxu Fijxu force-pushed the track-unknown-innertube-errors branch from de06565 to 43f877f Compare September 13, 2025 21:32
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.

Metrics: Track No valid URL to decipher too Metrics: track video unavailable too
3 participants