Skip to content

Try to infer runner is on hosted/ghes when githuburl is empty.#4254

Merged
TingluoHuang merged 2 commits intomainfrom
users/tihuang/setuptelemtry
Feb 18, 2026
Merged

Try to infer runner is on hosted/ghes when githuburl is empty.#4254
TingluoHuang merged 2 commits intomainfrom
users/tihuang/setuptelemtry

Conversation

@TingluoHuang
Copy link
Member

@TingluoHuang TingluoHuang requested a review from a team as a code owner February 18, 2026 02:44
Copilot AI review requested due to automatic review settings February 18, 2026 02:44
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 inference logic to determine whether a runner is on a hosted server or GHES when the GitHubUrl field is empty (as occurs with JIT-configured runners). The change attempts to infer the server type by examining ServerUrl and ServerUrlV2 fields and checking their domain patterns against known hosted service domains.

Changes:

  • Added fallback logic in RunnerSettings.IsHostedServer property getter to infer hosted/GHES status from ServerUrl and ServerUrlV2 when GitHubUrl is empty
  • Added support for GITHUB_ACTIONS_RUNNER_FORCE_GHES environment variable override in the new inference path
  • Added domain pattern checks for various hosted service domains (actions.githubusercontent.com, codedev.ms, githubapp.com, ghe.com, actions.localhost, ghe.localhost)
Comments suppressed due to low confidence (1)

src/Runner.Common/ConfigurationStore.cs:99

  • Creating a UriBuilder with an invalid or malformed URL will throw an exception (UriFormatException). If ServerUrlV2 contains an invalid URL, this will cause an unhandled exception. While this scenario might be rare in production, consider adding error handling or validation to gracefully handle malformed URLs and prevent unexpected crashes.
                        var serverUrlV2 = new UriBuilder(ServerUrlV2);

Comment on lines +78 to +106
else
{
// feature flag env in case the new logic is wrong.
if (StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_FORCE_EMPTY_GITHUB_URL_IS_HOSTED")))
{
return true;
}

// GitHubUrl will be empty for jit configured runner
// We will try to infer it from the ServerUrl/ServerUrlV2
if (StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_FORCE_GHES")))
{
// Allow env to override and force GHES in case the inference logic is wrong.
return false;
}

if (!string.IsNullOrEmpty(ServerUrl))
{
// pipelines services
var serverUrl = new UriBuilder(ServerUrl);
return serverUrl.Host.EndsWith(".actions.githubusercontent.com", StringComparison.OrdinalIgnoreCase)
|| serverUrl.Host.EndsWith(".codedev.ms", StringComparison.OrdinalIgnoreCase);
}

if (!string.IsNullOrEmpty(ServerUrlV2))
{
// broker-listener
var serverUrlV2 = new UriBuilder(ServerUrlV2);
return serverUrlV2.Host.EndsWith(".actions.githubusercontent.com", StringComparison.OrdinalIgnoreCase)
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

According to the project's coding guidelines, changes should be safeguarded by a feature flag wherever possible. This new inference logic for determining IsHostedServer introduces a significant behavioral change that could affect how runners are classified. Consider gating this new inference logic behind a feature flag to allow for gradual rollout and easy rollback if issues are discovered. You would need to declare a new feature flag in src/Runner.Common/Constants.cs in the Constants.Runner.Features class.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need a new feature flag? Could add a new getter IsHostedServer_New and put the burden on caller to check feature flag and call the correct getter.

Copy link
Member Author

Choose a reason for hiding this comment

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

i added the GITHUB_ACTIONS_RUNNER_FORCE_EMPTY_GITHUB_URL_IS_HOSTED in case any of the new code is broken.

@TingluoHuang TingluoHuang merged commit 72189aa into main Feb 18, 2026
12 checks passed
@TingluoHuang TingluoHuang deleted the users/tihuang/setuptelemtry branch February 18, 2026 17:00
ramil-bitrise pushed a commit to bitrise-io/github-runner that referenced this pull request Feb 24, 2026
ramil-bitrise pushed a commit to bitrise-io/github-runner that referenced this pull request Feb 24, 2026
dawidmalina pushed a commit to dawidmalina/github-runner that referenced this pull request Feb 26, 2026
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.

3 participants