Clean up deferred issue update helper - #13584
Merged
Merged
Conversation
…eOptions The deferredUpdateIssueOptions helper in both create and edit returned a partially-populated DeferredUpdateIssueOptions struct alongside the error on every failure path. Callers always discard the struct on err, so the partial value is invisible today but invites future misuse. Return a zero-value struct on error so the contract matches reality. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The --type (set) and --remove-type flags both prevent dropping into interactive mode, but they take different paths: --type lights up Editable.IssueType.Edited (covered by Editable.Dirty()), while --remove-type is the only type signal that has to be listed in hasDeferredFlags. Add a comment so the asymmetry stops surprising reviewers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens the contract of the deferredUpdateIssueOptions helper used by gh issue create and gh issue edit so it no longer returns a partially-populated api.DeferredUpdateIssueOptions when returning an error, and it documents why --type is intentionally excluded from hasDeferredFlags in gh issue edit.
Changes:
- Return a zero-value
api.DeferredUpdateIssueOptions{}on all error paths indeferredUpdateIssueOptions(create/edit) to avoid leaking partial structs. - Add an explanatory comment in
gh issue editclarifying the asymmetric handling of--typevs--remove-typeinhasDeferredFlags.
Show a summary per file
| File | Description |
|---|---|
| pkg/cmd/issue/edit/edit.go | Documents hasDeferredFlags behavior and ensures deferred update option helper returns a zero-value struct on error. |
| pkg/cmd/issue/create/create.go | Ensures deferred update option helper returns a zero-value struct on error. |
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: 0
BagToad
enabled auto-merge (squash)
June 4, 2026 16:13
babakks
approved these changes
Jun 4, 2026
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.
Description
Address two unresolved review threads from #13411: tighten the
deferredUpdateIssueOptionshelper to stop returning a partial struct on error, and document the asymmetric handling of--typeand--remove-typeingh issue edit.Key Points
pkg/cmd/issue/create/create.goandpkg/cmd/issue/edit/edit.goused to return a partially-populatedapi.DeferredUpdateIssueOptionsalongside the error on every failure path. Callers already discard the struct when err is non-nil, so the partial value was invisible in practice but invited future misuse. The fix returns a zero-value struct on error so the contract matches reality.hasDeferredFlagsblock ingh issue editlists--remove-typebut not--type. That is intentional (the set form flows throughEditable.IssueType.Editedand is picked up byEditable.Dirty()), but the split is non-obvious. A comment now makes the reasoning explicit.Notes for reviewers
Two atomic commits, both reviewable on their own:
refactor(issue): drop half-baked return value from deferredUpdateIssueOptions- the contract tightening acrosscreate.goandedit.go.docs(issue): clarify --type handling in edit hasDeferredFlags- comment only, no behavior change.No new tests: the refactor preserves end-to-end behavior, and existing run-function table tests (
Test_createRun,Test_editRun) already cover the affected paths.Additional Context