Skip to content

GitHub - Authorization failures due to empty Secret env var #2387

@anakin87

Description

@anakin87

Describe the bug
Accessing public repositories doesn't require a GitHub token.

When we set a Secret corresponding to an env var in github_token:

  • If the env var is not present, we fail with an expressive error message.
  • If the env var is set but empty (as it can happen on some platforms), we end up passing headers["Authorization"] = "Bearer", causing the request to fail.

I would not say it's a proper bug, but we can make the implementation more robust.

To Reproduce

from haystack_integrations.components.connectors.github import GitHubIssueViewer
from haystack.utils import Secret
import os

os.environ["GITHUB_TOKEN"] = ""

viewer = GitHubIssueViewer(github_token=Secret.from_env_var("GITHUB_TOKEN"))

result = viewer.run(url="https://github.com/deepset-ai/haystack-core-integrations/issues/2373")

# requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions