Type mismatch, got `MerchandiseShelf` expected `VideoDescriptionHeader` | ....
Steps to reproduce
Bug Description
The youtubei.js library is throwing ParsingError exceptions when it encounters a specific YouTube component type called MerchandiseShelf. The error occurs because the parser is expecting different component types but receives a MerchandiseShelf type instead, causing a type mismatch.
The specific error message is:
ParsingError: Type mismatch, got MerchandiseShelf expected VideoDescriptionHeader | ExpandableVideoDescriptionBody | VideoDescriptionMusicSection | VideoDescriptionInfocardsSection | VideoDescriptionCourseSection | VideoDescriptionTranscriptSection | VideoDescriptionTranscriptSection | HorizontalCardList | ReelShelf | VideoAttributesSectionView | HowThisWasMadeSectionView.
To Reproduce
The error occurs when the automation script attempts to process YouTube videos that contain merchandise shelves in their descriptions. This is evident from the log entries where several videos cause the same parsing error. The error appears consistently when the script calls a function that likely retrieves video metadata.
The error happens specifically for videos from channel UCGq-a57w-aPwyi3pW7XLiHw, including:
- "Secret Agent: If You're Easily Offended, You're Easily Manipulated! This 1 Trick Catches A Lie In 2s"
- "MrBeast: If You Want To Be Liked, Don't Help People & I Lost Tens Of Millions On Beast Games!"
- "The Sex Psychologist: We're Not Having Enough Sex! Fat Makes You Attractive! Dr Bill Von Hippel"
- "The Man That Makes Millionaires: Turn $0 to $10k With This Step By Step Formula! Alex Hormozi"
Expected Behavior
The library should either:
- Properly handle the
MerchandiseShelftype by adding it to the list of expected types in the parser - Gracefully skip unrecognized types without throwing exceptions
- Provide a more robust error handling mechanism to continue processing despite type mismatches
Additional Context
- The error occurs in the parser at line 15776 of the
youtubei.jslibrary. - Despite the errors, the script appears to continue running, suggesting there might be some error handling in place, but the parsing errors are still being logged.
- The version of youtubei.js being used is 13.1.0 as indicated in the error objects.
- These errors appear to have started occurring recently, likely due to YouTube introducing or modifying the
MerchandiseShelfcomponent in their API/website structure. - The errors specifically happen when processing the structured description content of videos from certain channels, suggesting those channels have enabled merchandise shelves in their video descriptions.
The issue seems to be related to YouTube's interface changes that the library hasn't been updated to handle yet. A fix would likely require updating the parser to recognize and properly handle the MerchandiseShelf type.
Failure Logs
ParsingError: Type mismatch, got MerchandiseShelf expected VideoDescriptionHeader | ExpandableVideoDescriptionBody | VideoDescriptionMusicSection | VideoDescriptionInfocardsSection | VideoDescriptionCourseSection | VideoDescriptionTranscriptSection | VideoDescriptionTranscriptSection | HorizontalCardList | ReelShelf | VideoAttributesSectionView | HowThisWasMadeSectionView.
Expected behavior
.
Current behavior
.
Version
Default
Anything else?
.
Checklist
- [x] I am running the latest version.
- [x] I checked the documentation and found no answer.
- [x] I have searched the existing issues and made sure this is not a duplicate.
- [x] I have provided sufficient information.
It is not an error and it will not cause any issues, unless you're specifically trying to access the element where that warning originated from. You can also turn off these parser warnings if you want (although I don't recommend, as it can be useful when investigating other problems.)