Skip to content

SearchResource.list type accepts list/tuple/set but is not comma-joined before request #195

Description

@chirag127

Problem

SearchResource.list type-hints type as Optional[Union[str, list, tuple, set]] and its docstring says "The value is a comma-separated list of resource types", but the value is passed straight into the params dict without normalization. When a caller passes a list, requests serializes it as repeated query params (type=video&type=channel), while YouTube Data API v3 expects a single comma-separated type=video,channel.

Steps

  1. pip install python-youtube==0.9.9
  2. from pyyoutube import Client; c = Client(api_key="...")
  3. c.search.list(q="news", type=["video", "channel"], max_results=10)

Expected

Request URL contains type=video%2Cchannel (single param, comma-joined), consistent with sibling params like parts which go through enf_parts.

Actual

Request URL contains type=video&type=channel (two params). The API silently ignores the second and applies only type=video.

File cite

pyyoutube/resources/search.py:233"type": type, bypasses enf_comma_separated. Compare to pyyoutube/resources/search.py:216 where parts is normalized via enf_parts. Signature declaring list/tuple/set support: pyyoutube/resources/search.py:42. Docstring: pyyoutube/resources/search.py:144-147.

Environment

python-youtube 0.9.9, requests >=2.28.0,<3.0.0, Python 3.9-3.14 per pyproject.toml.

Suggested fix

Wrap with enf_comma_separated(field="type", value=type) before insertion into params.

Thanks for maintaining sns-sdks/python-youtube!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions