Skip to content

fix(feedback): submit feedback when the repo has no feedback label - #1396

Merged
clay-good merged 2 commits into
Fission-AI:mainfrom
clay-good:fix/feedback-label-fallback
Jul 20, 2026
Merged

fix(feedback): submit feedback when the repo has no feedback label#1396
clay-good merged 2 commits into
Fission-AI:mainfrom
clay-good:fix/feedback-label-fallback

Conversation

@clay-good

@clay-good clay-good commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Status: Ready for review. Refs #1091 (see Scope — this does not remove the need to create the label).

What was wrong

openspec feedback "..." fails for every user, on every run.

The command always asks GitHub to apply a feedback label, but this repository does not define one. gh resolves label names before creating the issue, so it refuses outright:

$ openspec feedback "the archive workflow is great" --body "Using it daily."
could not add label: labels not found: feedback
$ echo $?
1

The command then exits non-zero and throws away the feedback the user just composed.

Easy to confirm: gh label list --repo Fission-AI/OpenSpec returns 29 labels and no feedback. Every Feedback:-titled issue in this repo (#1263, #1092, #1093, #1094) carries no labels at all.

How it was fixed

When — and only when — gh's stderr reports it could not add the label, retry once without it and say so:

✓ Feedback submitted successfully!
Issue URL: https://github.com/Fission-AI/OpenSpec/issues/9999

Note: created without the 'feedback' label because the repository does not define it.

If the feedback label is created later, the first attempt succeeds again and the retry never runs.

Matching stderr only is deliberate. Node puts the whole command line into error.message, and that command line contains the user's own title and body — so matching the message would let feedback text like "gh could not add label bug report" trigger a retry on an unrelated failure. There is a regression test for exactly that.

Proof it works

Verified against a stubbed gh on an isolated PATH (no real gh reachable, no issues created):

Scenario gh issue create calls Exit Result
Label missing (the bug) 2 — labeled, then unlabeled 0 issue created + note
Label exists 1, with --label feedback 0 unchanged, no note
Network failure 1, no retry 1 gh's error, gh's exit code
Network failure + "could not add label" in the user's text 1, no retry 1 gate not fooled

Before/after on the reported bug:

Before After
Output could not add label: labels not found: feedback ✓ Feedback submitted successfully!
Exit code 1 0
The feedback discarded filed as an issue

Tests: 16 in feedback.test.ts, including no-retry-on-other-errors, no-retry-when-the-text-mentions-the-label-error, exit-code preservation when the unlabeled retry fails, and silence about the label on the happy path. Full suite 2026 passed (only the 17 known environment-only zsh-installer failures). tsc --noEmit and eslint clean.

Why this is not a breaking change

Every failure mode that exists today behaves identically, verified by running both builds side by side: gh missing, gh unauthenticated, network, 403, 422, 502, issues-disabled (exit 4) — same stdout, same stderr, same exit code, same number of gh calls. handleFallback is byte-identical to main and does not appear in the diff.

The retry cannot duplicate an issue: gh maps label names to IDs client-side before the create mutation (params.goLabelsToIDs), so a label failure means nothing was created. And if gh ever rewords that error, the retry simply stops firing and behavior reverts to today's.

Spec

openspec/specs/cli-feedback/spec.md gains a scenario for the unlabeled path, and its gh CLI execution failure scenario is narrowed to exclude that case (it still requires gh's exit code and no retry for everything else). The network-failure and fallback scenarios are unchanged and still hold. openspec validate cli-feedback --type spec passes.

Scope

This makes the CLI resilient; it does not do what #1091 primarily asks. Creating the feedback label is still worth doing, and is strictly better on reach: it fixes every already-released version immediately, whereas this change only helps after the next release. Hence Refs rather than Closes — please close #1091 when the label exists.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • openspec feedback now succeeds when the repository lacks the feedback label by creating the issue without that label.
    • Displays the created issue URL and clearly indicates when the label could not be applied.
    • Preserves the original CLI error details and exit code for other failures.

@clay-good
clay-good requested a review from TabishB as a code owner July 20, 2026 18:57
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The feedback command centralizes GitHub issue creation, retries without the feedback label when unavailable, and reports the issue URL or CLI error. Tests and specifications cover successful retries and retry failures.

Changes

Feedback submission flow

Layer / File(s) Summary
Issue creation and retry handling
src/commands/feedback.ts, openspec/specs/cli-feedback/spec.md, .changeset/feedback-missing-label-retry.md
Adds GitHub CLI error classification, centralized issue creation, unlabeled retry handling, preserved exit codes, and documentation for the fallback behavior.
Retry and failure coverage
test/commands/feedback.test.ts
Verifies successful submissions, non-label failures without retries, missing-label retries, and failed retries preserving the second exit code.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant FeedbackCommand
  participant ghCLI
  participant Console
  FeedbackCommand->>ghCLI: Create issue with feedback label
  ghCLI-->>FeedbackCommand: Issue URL or missing-label error
  FeedbackCommand->>ghCLI: Retry issue creation without labels
  ghCLI-->>FeedbackCommand: Issue URL or CLI error
  FeedbackCommand->>Console: Print URL, label note, or error details
Loading

Possibly related PRs

Suggested reviewers: tabishb

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR uses a no-label retry, but #1091 requested adding a feedback label or falling back to another existing label. Add the feedback label as requested, or switch the fallback to a documented existing label like question or enhancement.
✅ Passed checks (4 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The code, tests, and spec all stay within the feedback-label fallback scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: retrying feedback submission when the repository lacks the feedback label.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/commands/feedback.ts`:
- Around line 160-178: Update submitViaGhCli so the fallback createIssue call
without labels is attempted only when the first createIssue error indicates the
missing “feedback” label condition. For all other failures, call handleFallback
directly with the original error via describeGhError, avoiding retries that
could create duplicate issues.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 83f7b7c8-017d-4ebf-adae-3c94f53e88fa

📥 Commits

Reviewing files that changed from the base of the PR and between a13abea and 6b5b245.

📒 Files selected for processing (2)
  • src/commands/feedback.ts
  • test/commands/feedback.test.ts

Comment thread src/commands/feedback.ts
@clay-good
clay-good force-pushed the fix/feedback-label-fallback branch from 6b5b245 to 9c22939 Compare July 20, 2026 19:08

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/commands/feedback.ts`:
- Around line 122-130: Update isMissingLabelError to inspect only error.stderr
when detecting the gh “could not add label” response; remove error.message from
the combined output so user-provided command arguments cannot trigger an
incorrect retry.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1d2683b3-ca8a-4e45-9b7c-213f39b6257f

📥 Commits

Reviewing files that changed from the base of the PR and between 6b5b245 and 9c22939.

📒 Files selected for processing (4)
  • .changeset/feedback-missing-label-retry.md
  • openspec/specs/cli-feedback/spec.md
  • src/commands/feedback.ts
  • test/commands/feedback.test.ts

Comment thread src/commands/feedback.ts
`openspec feedback` passed `--label feedback` unconditionally, but the
repository does not define that label. gh resolves label names before
creating the issue, so it failed with "could not add label: labels not
found: feedback" on every invocation and the command exited non-zero,
discarding the feedback the user had just composed.

Retry once without the label when — and only when — gh's stderr reports
that it could not add the label, and tell the user the label was not
applied. Every other failure keeps its existing behavior: print gh's error
and exit with gh's exit code, with no retry. Only stderr is matched,
because the error message also embeds the command line, which carries the
user's own feedback text.

The cli-feedback spec gains a scenario for the unlabeled path, and its
gh-failure scenario is narrowed to exclude it. The fallback scenarios are
unchanged.

Refs Fission-AI#1091

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@clay-good
clay-good force-pushed the fix/feedback-label-fallback branch from 9c22939 to 1bf085f Compare July 20, 2026 19:22

@alfred-openspec alfred-openspec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified against GitHub CLI v2.96.0 that label resolution happens before the issue-create mutation, so this narrow stderr-gated retry cannot duplicate an issue. All 16 focused feedback tests pass locally at 4b9ec3d and the exact-head CI matrix is green, so this is approved.

@clay-good
clay-good added this pull request to the merge queue Jul 20, 2026
Merged via the queue into Fission-AI:main with commit 60f720c Jul 20, 2026
11 checks passed
@clay-good
clay-good deleted the fix/feedback-label-fallback branch July 20, 2026 19:48
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.

[Feature Request] Add 'feedback' label for CLI feedback command

2 participants