Conversation
…ontext when explicit thread_id is provided Agent-Logs-Url: https://github.com/github/gh-aw/sessions/2e5ab53b-1616-429c-9017-f04d662c5d93 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Hey The PR is well-structured: the implementation change is minimal and surgical, the existing test is correctly updated to reflect the new expected behaviour, and a dedicated new test covers the schedule-trigger scenario with GraphQL call assertions. The PR description clearly explains the problem and the solution. This looks ready for maintainer review! 🚀 This review was generated by the contribution-checker agent.
|
There was a problem hiding this comment.
Pull request overview
This PR updates the resolve_pull_request_review_thread handler to allow resolving an explicitly provided thread_id even when the workflow was triggered without a pull request context (e.g., schedule / workflow_dispatch), and adjusts tests to cover the new behavior.
Changes:
- Relax legacy-mode behavior to no longer hard-fail when
triggeringPRNumberis absent; instead logs and proceeds whenthread_idis explicit. - Update the “non-PR context” test to expect success with an explicit
thread_id. - Add a new test covering schedule-triggered behavior with GraphQL call assertions.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/resolve_pr_review_thread.cjs | Adjusts legacy-mode scoping logic to permit thread resolution without a triggering PR number when thread_id is provided. |
| actions/setup/js/resolve_pr_review_thread.test.cjs | Updates/extends tests to validate success paths for non-PR contexts (including schedule triggers). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
| // Default (legacy) mode: scope to triggering PR only when a triggering PR exists | ||
| if (!triggeringPRNumber) { | ||
| core.warning("Cannot resolve review thread: not running in a pull request context"); | ||
| return { | ||
| success: false, | ||
| error: "Cannot resolve review threads outside of a pull request context", | ||
| }; | ||
| } | ||
|
|
||
| if (threadPRNumber !== triggeringPRNumber) { | ||
| // No triggering PR (e.g. schedule/workflow_dispatch trigger) but an explicit thread_id | ||
| // was provided and resolved to a specific PR via the API — allow the resolution to proceed | ||
| core.info(`No triggering PR context; resolving thread ${threadId} via explicit thread_id (PR #${threadPRNumber})`); | ||
| } else if (threadPRNumber !== triggeringPRNumber) { |
There was a problem hiding this comment.
In legacy mode (no explicit target-repo/allowed_repos), this new branch allows resolving a thread when triggeringPRNumber is missing without any repository scoping. If a per-handler github-token is configured (PAT/App) with access to multiple repos, a schedule/workflow_dispatch run could now resolve review threads in other repositories, bypassing the repo allowlist logic that only runs when hasExplicitTargetConfig is true.
To keep the behavior least-privilege while still supporting schedule/manual triggers, add a repo validation in the legacy path (e.g., require threadRepo and ensure it matches defaultTargetRepo, or call validateTargetRepo(threadRepo, defaultTargetRepo, allowedRepos) even when hasExplicitTargetConfig is false) and fail closed on mismatch/unknown repo.
See below for a potential fix:
// Default (legacy) mode: keep least-privilege behavior by requiring the resolved thread
// to belong to the default/allowed repository set even when there is no triggering PR.
if (!threadRepo) {
core.warning(`Unable to determine repository for review thread ${threadId}; refusing to resolve in legacy mode`);
return {
success: false,
error: `Unable to determine repository for review thread ${threadId}`,
};
}
const legacyRepoValidation = validateTargetRepo(threadRepo, defaultTargetRepo, allowedRepos);
if (!legacyRepoValidation.valid) {
core.warning(`Thread ${threadId} repository ${threadRepo} is not allowed in legacy mode`);
return {
success: false,
error: legacyRepoValidation.error || `Repository ${threadRepo} is not allowed for this handler`,
};
}
// Scope to triggering PR only when a triggering PR exists
if (!triggeringPRNumber) {
// No triggering PR (e.g. schedule/workflow_dispatch trigger), but the thread has been
// resolved to a specific allowed repository via the API — allow the resolution to proceed
core.info(`No triggering PR context; resolving thread ${threadId} via explicit thread_id (PR #${threadPRNumber} in ${threadRepo})`);
🧪 Test Quality Sentinel ReportTest Quality Score: 80/100✅ Excellent
Test Classification Details📋 All 2 modified/new tests
Test AnalysisTest 1 (modified): This test was renamed and updated from the previous Test 2 (new): Adds specific coverage for schedule-triggered workflows (empty Test Inflation NoteThe raw addition ratio (29 test lines / 5 production lines = 5.8:1) triggers the inflation flag, but the context is benign: the production change was primarily a simplification (9 lines deleted, 5 added), while the tests expand coverage for two new valid trigger scenarios. The added test lines are not padding — they are meaningful assertions directly tied to the behavioral change. Language SupportTests analyzed:
No Go test files were changed in this PR. Verdict
📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.
|
|
@copilot review comments |
…e (security) Agent-Logs-Url: https://github.com/github/gh-aw/sessions/8df6cfba-9708-4766-a959-df1fa83578e4 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Addressed in 68d2015. The legacy mode path now validates the thread's repository against |
In default (legacy) mode, the handler always required
triggeringPRNumber— causing it to reject calls from schedule/workflow_dispatch workflows even when an explicitthread_idhad already been resolved to a specific PR via the GraphQL API.Changes
resolve_pr_review_thread.cjs: In the default/legacyelsebranch, replace the hard failure whentriggeringPRNumberis absent with repo validation and aninfolog; skip the PR-number match check when there is no triggering PR. The check is preserved when a triggering PR is present. To maintain least-privilege, the legacy path now also validates the thread's repository againstdefaultTargetRepo/allowedRepos(viavalidateTargetRepo) and fails closed if the repo cannot be determined or is not allowed.resolve_pr_review_thread.test.cjs: Updated the existing "reject when not in a pull request context" test (now expects success with a validthread_idin the default repo); added tests covering the schedule-trigger scenario with GraphQL call assertions, as well as failure cases for null thread repo and cross-repo threads in legacy mode.