Merged
Conversation
Signed-off-by: Babak K. Shandiz <babakks@github.com>
BagToad
reviewed
Apr 19, 2025
BagToad
reviewed
Apr 19, 2025
BagToad
reviewed
Apr 19, 2025
Member
BagToad
left a comment
There was a problem hiding this comment.
✨ LGTM, but I left a question that we should resolve before merging 😁
jtmcg
reviewed
Apr 21, 2025
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
…ility Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Member
Author
|
I also found a couple of more cases and fixed them. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new StatusJSONResponse helper, adds a JSONErrorResponse wrapper for HTTP errors, and updates existing tests to use the new helper for consistency.
- Added
StatusJSONResponseandJSONErrorResponseinpkg/httpmock/stub.go - Replaced direct
StatusJSONResponsecalls withJSONErrorResponsein several test files - Adjusted tests to use typed error stubs and added
wantErrStringassertions
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/httpmock/stub.go | Added StatusJSONResponse and JSONErrorResponse |
| pkg/cmd/run/watch/watch_test.go | Switched to JSONErrorResponse for 404 stubs |
| pkg/cmd/repo/autolink/delete/http_test.go | Changed stub response type and StatusJSONResponse usage |
| pkg/cmd/gpg-key/delete/delete_test.go | Updated to use JSONErrorResponse for GPG key errors |
| pkg/cmd/gist/delete/delete_test.go | Refactored error assertions and replaced response helper |
Comments suppressed due to low confidence (2)
pkg/httpmock/stub.go:168
- StatusJSONResponse uses httpResponse, which does not set the Content-Type header. To ensure clients recognize the payload as JSON, use httpResponseWithHeader with "application/json" or explicitly add the header.
func StatusJSONResponse(status int, body interface{}) Responder {
pkg/httpmock/stub.go:180
- Consider adding unit tests for StatusJSONResponse and JSONErrorResponse to verify status codes, JSON encoding, and the Content-Type header are correctly applied.
func JSONErrorResponse(status int, err api.HTTPError) Responder {
rancorm
pushed a commit
to rancorm/cli
that referenced
this pull request
May 3, 2025
* Fix `StatusJSONResponse` usage Signed-off-by: Babak K. Shandiz <babakks@github.com> * Replace `assert` with `require` Signed-off-by: Babak K. Shandiz <babakks@github.com> * Improve assertion against errors Signed-off-by: Babak K. Shandiz <babakks@github.com> * Add `JSONErrorResponse` helper func Signed-off-by: Babak K. Shandiz <babakks@github.com> * Use `httpmock.JSONErrorResponse` Signed-off-by: Babak K. Shandiz <babakks@github.com> * Replace `StatusJSONResponse` to `JSONErrorResponse` for better readibility Signed-off-by: Babak K. Shandiz <babakks@github.com> * Fix improper use of `StatsJSONResponse` Signed-off-by: Babak K. Shandiz <babakks@github.com> --------- Signed-off-by: Babak K. Shandiz <babakks@github.com>
tmeijn
pushed a commit
to tmeijn/dotfiles
that referenced
this pull request
May 20, 2025
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [cli/cli](https://github.com/cli/cli) | minor | `v2.72.0` -> `v2.73.0` | 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.73.0`](https://github.com/cli/cli/releases/tag/v2.73.0): GitHub CLI 2.73.0 [Compare Source](cli/cli@v2.72.0...v2.73.0) ####Copilot Coding Agent Support You can now assign issues to GitHub Copilot directly from `gh`, just as you would assign them to a teammate. Use `gh issue edit <number> --add-assignee @​copilot` to assign the GitHub Copilot coding agent, and Copilot will work in the background to understand the issue, propose a solution, and open a pull request when it's ready for your review. If you run `gh issue edit` interactively, `Copilot (AI)` will be displayed as a potential assignee. This feature is available for GitHub Copilot Pro+ and Copilot Enterprise subscribers. For more details, refer to [the full changelog post for Copilot coding agent](https://github.blog/changelog/2025-05-19-github-copilot-coding-agent-in-public-preview/). #### What's Changed ##### ✨ Features - Copilot is assignable to issues and pull requests with `issue edit` and `pr edit` by [@​BagToad](https://github.com/BagToad) in cli/cli#10992 - `gh issue edit`: actors are assignable to issues by [@​BagToad](https://github.com/BagToad) in cli/cli#10960 - `gh pr edit`: Assign actors to pull requests by [@​BagToad](https://github.com/BagToad) in cli/cli#10984 - `issue edit`, `pr edit`: handle display names in interactive assignee editing by [@​BagToad](https://github.com/BagToad) in cli/cli#10990 - `issue edit`, `pr edit`: Support special non-interactive (flags) assignee name `@copilot` by [@​BagToad](https://github.com/BagToad) in cli/cli#10991 - \[gh issue/pr comment] Add support for last comment delete for issues and MRs by [@​sinansonmez](https://github.com/sinansonmez) in cli/cli#10596 - \[gh issue view] Expose `closedByPullRequestsReferences` JSON field by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10941 - Accessible prompter always displays selection defaults in a format readable by a screen reader by [@​BagToad](https://github.com/BagToad) in cli/cli#10937 ##### 🐛 Fixes - Fix `StatusJSONResponse` usage by [@​babakks](https://github.com/babakks) in cli/cli#10810 - Fix panic on `gh pr view 0` by [@​nopcoder](https://github.com/nopcoder) in cli/cli#10729 - Fix flakey test for accessible prompter by [@​BagToad](https://github.com/BagToad) in cli/cli#10918 - Fix accessible prompter flaky tests by [@​babakks](https://github.com/babakks) in cli/cli#10977 - Handle missing archive URLs on release download by [@​williammartin](https://github.com/williammartin) in cli/cli#10947 - Fix bug when removing all MR reviewers by [@​babakks](https://github.com/babakks) in cli/cli#10975 ##### 📚 Docs & Chores - Feature detect v1 projects on pr view by [@​williammartin](https://github.com/williammartin) in cli/cli#10821 - Feature detect v1 projects on non-interactive pr create by [@​williammartin](https://github.com/williammartin) in cli/cli#10909 - Feature detect v1 projects on web mode pr create by [@​williammartin](https://github.com/williammartin) in cli/cli#10911 - Feature detect v1 projects on interactive `pr create` by [@​williammartin](https://github.com/williammartin) in cli/cli#10915 - Feature detect v1 projects on pr edit by [@​williammartin](https://github.com/williammartin) in cli/cli#10942 - Move predicate type filtering in `gh attestation verify` by [@​malancas](https://github.com/malancas) in cli/cli#10670 - Improve assertion for disabled echo mode by [@​babakks](https://github.com/babakks) in cli/cli#10927 #####
Dependencies - chore(deps): bump actions/attest-build-provenance from 2.2.2 to 2.3.0 by [@​dependabot](https://github.com/dependabot) in cli/cli#10886 - chore(deps): bump github.com/cpuguy83/go-md2man/v2 from 2.0.6 to 2.0.7 by [@​dependabot](https://github.com/dependabot) in cli/cli#10869 #### What's Changed #### New Contributors - [@​sinansonmez](https://github.com/sinansonmez) made their first contribution in cli/cli#10596 - [@​nopcoder](https://github.com/nopcoder) made their first contribution in cli/cli#10729 **Full Changelog**: cli/cli@v2.72.0...v2.73.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, 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:eyJjcmVhdGVkSW5WZXIiOiI0MC4xNS4wIiwidXBkYXRlZEluVmVyIjoiNDAuMTUuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While reviewing a PR I noticed a wrong usage of
StatusJSONResponseand that led me to find another instance, which is now fixed in this PR.