Skip to content

ralph-triage.js hardcodes api.github.com, causing 401 on GitHub Enterprise #1142

Closed

Description

@graememel-kap

Summary

Squad Heartbeat (Ralph) / heartbeat fails on GitHub Enterprise because the triage script sends API requests to api.github.com instead of the GHE API host.


Failure observed

Workflow logs show:

GitHub API 401: {
  "message": "Bad credentials",
  "documentation_url": "https://docs.github.com/rest",
  "status": "401"
}

This happens even though GITHUB_TOKEN is present and checkout works.


Root cause

In .squad/templates/ralph-triage.js, API requests are hardcoded to:

hostname: 'api.github.com'

On GHE, the token is only valid for the enterprise API (https:///api/v3), so calls to github.com return 401.


Expected behavior

Ralph triage should use:

  1. GITHUB_API_URL when provided
  2. otherwise GITHUB_SERVER_URL + /api/v3
  3. fallback to https://api.github.com for github.com environments

Proposed fix

Update ralph-triage.js request construction to derive host/path from environment instead of hardcoding api.github.com.


Repro steps

  1. Run Squad Heartbeat (Ralph) in a GHE repo.
  2. Ensure .squad/templates/ralph-triage.js is present.
  3. Observe failure in Ralph - Smart triage with 401 Bad credentials.

Acceptance criteria

  • Heartbeat succeeds on GHE with standard GITHUB_TOKEN.
  • No regression on github.com-hosted repos.
  • Triage results are generated and downstream steps run as expected.

Activity

  1. omercangumus commented on Jul 2, 2026

    @omercangumus
    Contributor

    Thanks for the detailed repro and proposed fix — I'll take this one.

    Plan: githubRequestJson() in .squad-templates/ralph-triage.js currently hardcodes hostname: 'api.github.com' in the https.request() options. I'll add a small resolveGithubApiBase() helper that picks the API base in the order you outlined — GITHUB_API_URL first, then GITHUB_SERVER_URL + /api/v3, then falling back to https://api.github.com — and build the request from a URL object instead of a hardcoded hostname/path pair. I'll add a unit test covering all three resolution branches, then run node scripts/sync-templates.mjs --sync so the fix propagates to the three mirrored copies (templates/, packages/squad-cli/templates/, packages/squad-sdk/templates/) that test/template-sync.test.ts checks for byte-for-byte parity.

  2. added a commit that references this issue on Jul 3, 2026
    58ca57b
  3. added a commit that references this issue on Jul 10, 2026
    d60b9ff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triagedIssue has been triagedwave:2-soonWave 2 — next 2-4 weeks

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions