Summary
agents-chat-action cannot be used on GitHub Enterprise Server (GHES) because the github-url input is validated against a regex that is hardcoded to github.com. On GHES, every valid issue/PR URL (e.g. https://github.example.com/owner/repo/pull/1) fails validation and the action exits before ever posting a comment.
Where
src/comment.ts lines 20-21:
const GITHUB_URL_REGEX =
/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/(?:issues|pull)\/(\d+)\/?(?:[?#].*)?$/;
The same restriction is echoed in:
src/action.ts — error message: "The action rejects non-github.com hosts ..."
README.md — github-url input docs: "only https://github.com/<owner>/<repo>/... are accepted"
Proposal
Anchor the regex to the runner-provided GITHUB_SERVER_URL env var instead of the literal string github.com. The Actions runner always sets GITHUB_SERVER_URL to the current server (https://github.com on dotcom, https://github.example.com on GHES), so this makes the action portable without weakening the existing security property — the host anchor is still runner-controlled, not user-controlled, so a workflow that templates user input into github-url still cannot redirect the action to an attacker-chosen host.
Rough shape:
- In
src/comment.ts, replace the module-level constant with a builder that escapes regex metacharacters in the host:
export function buildGithubURLRegex(serverURL: string): RegExp {
const base = serverURL.replace(/\/$/, "").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
return new RegExp(
`^${base}/([^/]+)/([^/]+)/(?:issues|pull)/(\\d+)/?(?:[?#].*)?$`,
);
}
- Have
parseGithubItemURL accept the server URL (plumbed in from action.ts, consistent with the existing pattern of keeping process.env reads at the edge). Provide a https://github.com fallback for tests / non-Actions callers.
- Update the error message in
action.ts and the github-url row in README.md to describe the accepted host as "the current GitHub server ($GITHUB_SERVER_URL)" rather than github.com.
- Add tests in
src/comment.test.ts:
- dotcom URL still parses,
- a GHES URL (e.g.
https://github.acme.example/owner/repo/pull/1) parses when GITHUB_SERVER_URL matches,
- a URL whose host does not match
GITHUB_SERVER_URL is still rejected (the security-relevant case).
Open questions
- Read
GITHUB_SERVER_URL inside the helper, or plumb it through ActionInputs? The rest of the codebase keeps env reads at the edge, so plumbing it in is more consistent but changes the parseGithubItemURL signature that comment.test.ts calls directly.
- Confirm the fallback host when
GITHUB_SERVER_URL is unset (only relevant outside a real Actions runner). Presumably https://github.com.
Created on behalf of @mdanter
Summary
agents-chat-actioncannot be used on GitHub Enterprise Server (GHES) because thegithub-urlinput is validated against a regex that is hardcoded togithub.com. On GHES, every valid issue/PR URL (e.g.https://github.example.com/owner/repo/pull/1) fails validation and the action exits before ever posting a comment.Where
src/comment.tslines 20-21:The same restriction is echoed in:
src/action.ts— error message:"The action rejects non-github.com hosts ..."README.md—github-urlinput docs:"only https://github.com/<owner>/<repo>/... are accepted"Proposal
Anchor the regex to the runner-provided
GITHUB_SERVER_URLenv var instead of the literal stringgithub.com. The Actions runner always setsGITHUB_SERVER_URLto the current server (https://github.comon dotcom,https://github.example.comon GHES), so this makes the action portable without weakening the existing security property — the host anchor is still runner-controlled, not user-controlled, so a workflow that templates user input intogithub-urlstill cannot redirect the action to an attacker-chosen host.Rough shape:
src/comment.ts, replace the module-level constant with a builder that escapes regex metacharacters in the host:parseGithubItemURLaccept the server URL (plumbed in fromaction.ts, consistent with the existing pattern of keepingprocess.envreads at the edge). Provide ahttps://github.comfallback for tests / non-Actions callers.action.tsand thegithub-urlrow inREADME.mdto describe the accepted host as "the current GitHub server ($GITHUB_SERVER_URL)" rather thangithub.com.src/comment.test.ts:https://github.acme.example/owner/repo/pull/1) parses whenGITHUB_SERVER_URLmatches,GITHUB_SERVER_URLis still rejected (the security-relevant case).Open questions
GITHUB_SERVER_URLinside the helper, or plumb it throughActionInputs? The rest of the codebase keeps env reads at the edge, so plumbing it in is more consistent but changes theparseGithubItemURLsignature thatcomment.test.tscalls directly.GITHUB_SERVER_URLis unset (only relevant outside a real Actions runner). Presumablyhttps://github.com.Created on behalf of @mdanter