Skip to content

Commit 9cef0d9

Browse files
deyaaeldeenCopilot
andauthored
hero-scenarios: fall back to add-comment when file not in PR diff (#42334)
When hero-scenarios.md exists in the repo but isn't part of the PR's changed files, the agent was using create-pull-request-review-comment which fails with 'Path could not be resolved'. Now the prompt instructs the agent to check whether the file is in the PR diff first and fall back to add-comment when it isn't. Also makes the hero-scenarios.md filename check case-insensitive to handle existing HERO_SCENARIOS.md files. Co-authored-by: Deyaa Eldeen <deyaaeldeen@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 47103cd commit 9cef0d9

1 file changed

Lines changed: 31 additions & 12 deletions

File tree

.github/prompts/hero-scenarios-guidelines.md

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
## Step 1 — Check for Existing Hero Scenarios
1818

19-
Check whether the service already has a `hero-scenarios.md` file.
19+
Check whether the service already has a `hero-scenarios.md` file (the
20+
check should be case-insensitive — e.g., `HERO_SCENARIOS.md` counts).
2021
Look in the top-level service directory (e.g.,
2122
`specification/loadtestservice/hero-scenarios.md`) and in each spec subdirectory
2223
(e.g., `resource-manager/Microsoft.LoadTestService/loadtesting/hero-scenarios.md`,
@@ -267,19 +268,37 @@ The file should include:
267268
does, who it is for, and what problem it solves.
268269
2. **Hero scenarios** — the scenarios generated in Step 3.
269270

270-
**If a `hero-scenarios.md` already exists**, post an inline code suggestion on
271-
the file using `create-pull-request-review-comment`. Place the
272-
comment at the end of the file and use a GitHub suggestion block so the
273-
author can apply it with one click:
271+
**If a `hero-scenarios.md` already exists**, check whether the file is
272+
part of the PR diff (i.e., listed in the changed files of the pull request).
274273

275-
````
276-
```suggestion
277-
<the new scenario section as raw markdown>
278-
```
279-
````
274+
- **If the file IS in the PR diff**, post an inline code suggestion on
275+
the file using `create-pull-request-review-comment`. Place the
276+
comment at the end of the file and use a GitHub suggestion block so the
277+
author can apply it with one click:
278+
279+
````
280+
```suggestion
281+
<the new scenario section as raw markdown>
282+
```
283+
````
284+
285+
Then submit the review using `submit-pull-request-review` with event
286+
`COMMENT` and a one-sentence body summarizing what was suggested.
287+
288+
- **If the file is NOT in the PR diff**, use `add-comment` to post a
289+
PR comment instead (review comments can only be placed on files in the
290+
diff). Format it as:
291+
292+
```
293+
## 📖 Suggested additions to hero-scenarios.md
294+
295+
> **Path:** `specification/{service}/{specDir}/hero-scenarios.md`
296+
>
297+
> The existing `hero-scenarios.md` does not cover the API surface in
298+
> this PR. Consider adding the following scenarios:
280299
281-
Then submit the review using `submit-pull-request-review` with event
282-
`COMMENT` and a one-sentence body summarizing what was suggested.
300+
<the new scenario section as raw markdown — do NOT wrap it in a code fence>
301+
```
283302

284303
If the existing `hero-scenarios.md` already covers all the API surface in
285304
this PR, submit a `COMMENT` review with a one-sentence body confirming no

0 commit comments

Comments
 (0)