Skip to content

Conversation

@kevinbackhouse
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings February 10, 2026 21:11
@kevinbackhouse kevinbackhouse marked this pull request as ready for review February 10, 2026 21:13
Copy link
Contributor

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 pull request adds GITHUB_TOKEN as a third fallback option for AI API authentication, while also fixing a critical bug where COPILOT_TOKEN was not being properly checked. The change enhances flexibility for users, particularly those running in GitHub Actions environments where GITHUB_TOKEN is automatically available.

Changes:

  • Fixed missing check for COPILOT_TOKEN that would have prevented it from being used
  • Added GITHUB_TOKEN as a third fallback option in the token resolution chain
  • Updated the function docstring to document all three supported environment variables

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

token = os.getenv("GITHUB_TOKEN")
if token:
return token
raise RuntimeError("AI_API_TOKEN environment variable is not set.")
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

The error message at line 61 only mentions "AI_API_TOKEN environment variable is not set" but the function now accepts three different environment variables (AI_API_TOKEN, COPILOT_TOKEN, or GITHUB_TOKEN). The error message should be updated to reflect all three options to provide accurate guidance to users when none of them are set.

Suggested change
raise RuntimeError("AI_API_TOKEN environment variable is not set.")
raise RuntimeError(
"No API token found. Please set one of: AI_API_TOKEN, COPILOT_TOKEN, or GITHUB_TOKEN."
)

Copilot uses AI. Check for mistakes.
Comment on lines 46 to 61
def get_AI_token():
"""
Get the token for the AI API from the environment.
The environment variable can be named either AI_API_TOKEN
or COPILOT_TOKEN.
The environment variable can be named either AI_API_TOKEN,
COPILOT_TOKEN, or GITHUB_TOKEN.
"""
token = os.getenv("AI_API_TOKEN")
if token:
return token
token = os.getenv("COPILOT_TOKEN")
if token:
return token
token = os.getenv("GITHUB_TOKEN")
if token:
return token
raise RuntimeError("AI_API_TOKEN environment variable is not set.")
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

The new GITHUB_TOKEN fallback behavior and the fixed COPILOT_TOKEN check lack test coverage. Given that tests/test_api_endpoint_config.py contains comprehensive tests for the related get_AI_endpoint() function, similar tests should be added for get_AI_token() to verify the fallback chain works correctly (AI_API_TOKEN -> COPILOT_TOKEN -> GITHUB_TOKEN) and that the error is raised when none are set.

Copilot uses AI. Check for mistakes.
@kevinbackhouse kevinbackhouse marked this pull request as draft February 10, 2026 22:04
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.

1 participant