KEMBAR78
fix `gh pr edit`: do not fetch V1 projects on unsupported GitHub hosts by BagToad · Pull Request #11987 · cli/cli · GitHub
Skip to content

Conversation

@BagToad
Copy link
Member

@BagToad BagToad commented Oct 21, 2025

This pull request updates how project v1 support is handled when editing issues and pull requests. The main change is to pass explicit project v1 support information through the editing workflow, ensuring that project v1 options are only fetched and presented when supported by the repository. This affects function signatures, calls, and related tests for both issues and pull requests.

Fixes #11986

Update FetchOptions and related function signatures to accept a ProjectsV1Support parameter, enabling conditional logic based on project support. This change improves flexibility for handling project fields in issue and PR editing flows.
Added Detector field with EnabledDetectorMock to EditOptions in issue and PR edit command tests to ensure feature detection logic is exercised during test runs. Also updated EditableOptionsFetch signature in pr/edit/edit_test.go to include projectsV1Support parameter for compatibility with shared.FetchOptions.
@BagToad BagToad requested a review from a team as a code owner October 21, 2025 21:58
@BagToad BagToad requested review from babakks and Copilot and removed request for Copilot October 21, 2025 21:58
Comment on lines -416 to +417
ProjectsV1: editable.Projects.Edited,
ProjectsV1: editable.Projects.Edited && projectV1Support == gh.ProjectsV1Supported,
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the actual meat and potatoes. The rest of the changes are just to satisfy the interface change.

@BagToad BagToad requested a review from Copilot October 21, 2025 22:01
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 fixes an issue where project v1 data was being fetched on GitHub hosts that don't support project v1. The change adds explicit project v1 support checking by passing gh.ProjectsV1Support through the editing workflow, ensuring project v1 options are only fetched when supported by the repository.

  • Updated function signatures to accept gh.ProjectsV1Support parameter
  • Modified FetchOptions to conditionally fetch project v1 data based on support status
  • Added detector mock to test cases to support the new parameter

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/cmd/pr/shared/editable.go Updated FetchOptions signature to accept project v1 support parameter and conditionally fetch v1 projects
pkg/cmd/pr/edit/edit.go Updated interface and implementation to pass project v1 support status when fetching options
pkg/cmd/pr/edit/edit_test.go Updated test fetcher to match new function signature
pkg/cmd/issue/edit/edit.go Updated function signature to accept project v1 support parameter and pass it when fetching options
pkg/cmd/issue/edit/edit_test.go Added detector mocks to test options to support new parameter requirement

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@babakks babakks left a comment

Choose a reason for hiding this comment

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

LGTM! Can we also have a test to verify the Projects V1 data are not fetched?

Introduces a test case to ensure that when editing pull requests non-interactively and projects v1 is unsupported, v1 project metadata is not fetched and only v2 project queries are made.
@BagToad BagToad enabled auto-merge October 22, 2025 01:17
@BagToad BagToad merged commit 40512a8 into trunk Oct 22, 2025
11 checks passed
@BagToad BagToad deleted the kw/fix-projectsv1-fetching-in-pr-edit branch October 22, 2025 01:21
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Oct 22, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cli/cli](https://github.com/cli/cli) | patch | `v2.82.0` -> `v2.82.1` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>cli/cli (cli/cli)</summary>

### [`v2.82.1`](https://github.com/cli/cli/releases/tag/v2.82.1): GitHub CLI 2.82.1

[Compare Source](cli/cli@v2.82.0...v2.82.1)

#### Fix `gh pr edit` not detecting classic projects feature deprecation

`gh pr edit` was not correctly detecting the classic projects API deprecation. This release fixes that detection and avoids an incorrect fetch to the deprecated APIs.

This only impacted `gh pr edit` commands used to add or remove projects.

#### What's Changed

##### 🐛 Fixes

- fix `gh pr edit`: do not fetch V1 projects on unsupported GitHub hosts by [@&#8203;BagToad](https://github.com/BagToad) in [#&#8203;11987](cli/cli#11987)

##### :dependabot: Dependencies

- chore(deps): bump github/codeql-action from 3 to 4 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;11881](cli/cli#11881)
- chore(deps): Bump github.com/sigstore/sigstore-go from 1.1.0 to 1.1.3 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;11830](cli/cli#11830)
- chore(deps): bump github.com/gabriel-vasile/mimetype from 1.4.9 to 1.4.10 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;11659](cli/cli#11659)
- chore(deps): bump actions/attest-build-provenance from 2.4.0 to 3.0.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;11612](cli/cli#11612)

**Full Changelog**: <cli/cli@v2.82.0...v2.82.1>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNTIuOSIsInVwZGF0ZWRJblZlciI6IjQxLjE1Mi45IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
jbmichaels1984

This comment was marked as spam.

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.

CLI reports error when issuing pr edit trying to add the PR to a project

4 participants