Skip to content

Clean up deferred issue update helper - #13584

Merged
BagToad merged 2 commits into
trunkfrom
bagtoad/kw-issues-2-0-deferred-cleanup
Jun 4, 2026
Merged

Clean up deferred issue update helper#13584
BagToad merged 2 commits into
trunkfrom
bagtoad/kw-issues-2-0-deferred-cleanup

Conversation

@BagToad

@BagToad BagToad commented Jun 4, 2026

Copy link
Copy Markdown
Member

Description

Address two unresolved review threads from #13411: tighten the deferredUpdateIssueOptions helper to stop returning a partial struct on error, and document the asymmetric handling of --type and --remove-type in gh issue edit.

Key Points

  • The helper in pkg/cmd/issue/create/create.go and pkg/cmd/issue/edit/edit.go used to return a partially-populated api.DeferredUpdateIssueOptions alongside 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.
  • The hasDeferredFlags block in gh issue edit lists --remove-type but not --type. That is intentional (the set form flows through Editable.IssueType.Edited and is picked up by Editable.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:

  1. refactor(issue): drop half-baked return value from deferredUpdateIssueOptions - the contract tightening across create.go and edit.go.
  2. 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

BagToad and others added 2 commits June 4, 2026 10:03
…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>
@BagToad
BagToad requested a review from a team as a code owner June 4, 2026 16:09
@BagToad
BagToad requested review from babakks and Copilot June 4, 2026 16:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 in deferredUpdateIssueOptions (create/edit) to avoid leaking partial structs.
  • Add an explanatory comment in gh issue edit clarifying the asymmetric handling of --type vs --remove-type in hasDeferredFlags.
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
BagToad enabled auto-merge (squash) June 4, 2026 16:13
@BagToad
BagToad merged commit 0faf4b0 into trunk Jun 4, 2026
19 checks passed
@BagToad
BagToad deleted the bagtoad/kw-issues-2-0-deferred-cleanup branch June 4, 2026 16:54
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.

3 participants