Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getHashtag method fails with 400 status for certain Cyrillic hashtags #892

Open
4 tasks done
axercode opened this issue Feb 12, 2025 · 0 comments
Open
4 tasks done
Labels
bug Something isn't working good first issue Good for newcomers priority: medium

Comments

@axercode
Copy link

Steps to reproduce

Description

When using the getHashtag method with certain Cyrillic (non-ASCII) characters, the request fails with a 400 status code. The issue appears to be related to the encoding process in the getHashtag method, specifically in the parameter encoding step:

const params = encodeURIComponent(u8ToBase64(writer.finish()));

Reproduction Steps

  1. Initialize Innertube client
  2. Try to fetch hashtag data using getHashtag with Cyrillic characters
const response = await youtubei.getHashtag('биткоин');

Debug Information

I've noticed different encoding results for working vs non-working hashtags:

Working hashtag (#биток):

[getHashtag] Encoding hashtag: биток
[getHashtag] Params: 6gUOCgrQsdC40YLQvtC6GAE%3D

Failing hashtag (#биткоин):

[getHashtag] Encoding hashtag: биткоин
[getHashtag] Params: 6gUSCg7QsdC40YLQutC%2B0LjQvRg

The encoded parameters have different structures for working and non-working cases. The encoding process (u8ToBase64 followed by encodeURIComponent) seems to handle some Cyrillic strings correctly while failing with others.

Test Cases

Working hashtags:

  • биток, мир (Cyrillic word)
  • crypto (Latin characters)

Failing hashtags:

  • биткоин, море (Cyrillic word)
  • Other Cyrillic hashtags

Environment

  • YouTube.js version: 12.2.0
  • Node.js version: 23
  • Operating System: Linux

Additional Context

  • The same hashtags work correctly on YouTube's web interface
  • The issue seems to be related to the encoding process in the getHashtag method
  • This issue is specific to the getHashtag endpoint
  • The difference in encoded parameters between working and non-working cases suggests a potential issue with the encoding pipeline for certain Cyrillic strings

Failure Logs

InnertubeError: Request to https://www.youtube.com/youtubei/v1/browse?prettyPrint=false&alt=json failed with status 400
info: '{\n' +
    '  "error": {\n' +
    '    "code": 400,\n' +
    '    "message": "Request contains an invalid argument.",\n' +
    '    "errors": [\n' +
    '      {\n' +
    '        "message": "Request contains an invalid argument.",\n' +
    '        "domain": "global",\n' +
    '        "reason": "badRequest"\n' +
    '      }\n' +
    '    ],\n' +
    '    "status": "INVALID_ARGUMENT"\n' +
    '  }\n' +
    '}\n',
  date: 2025-02-12T08:02:09.288Z,
  version: '12.2.0'
}

Expected behavior

  • Should return hashtag data similar to what's returned for Latin character hashtags
  • Should work similarly to YouTube's web interface where Cyrillic hashtags are fully supported

Current behavior

  • Returns error 400 (Bad Request):
InnertubeError: Request to https://www.youtube.com/youtubei/v1/browse?prettyPrint=false&alt=json failed with status 400
{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "errors": [
      {
        "message": "Request contains an invalid argument.",
        "domain": "global",
        "reason": "badRequest"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}

Version

Default

Anything else?

No response

Checklist

  • I am running the latest version.
  • I checked the documentation and found no answer.
  • I have searched the existing issues and made sure this is not a duplicate.
  • I have provided sufficient information.
@axercode axercode added the bug Something isn't working label Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers priority: medium
Projects
None yet
Development

No branches or pull requests

2 participants