Skip to content

fix(issue): ensure --into flag is resolved with multiple positional args - #1256

Merged
BYK merged 3 commits into
mainfrom
seer/fix-issue-merge-into-flag
Jul 28, 2026
Merged

fix(issue): ensure --into flag is resolved with multiple positional args#1256
BYK merged 3 commits into
mainfrom
seer/fix-issue-merge-into-flag

Conversation

@sentry

@sentry sentry Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Previously, the --into flag was only appended to the list of effective arguments if exactly one positional argument was provided to sentry issue merge. This meant that if a user ran a command like sentry issue merge CLI-A CLI-B --into CLI-C, the CLI-C issue specified by --into would not be included in the issues resolved for merging.

This omission caused orderForMerge to fail, as it would attempt to find CLI-C among only CLI-A and CLI-B, leading to a ValidationError stating that `--into 'CLI-C' did not match any of the provided issues.

This change modifies the logic for constructing effectiveArgs to always append flags.into if it is present and not already included in the positional arguments, regardless of the number of positional arguments. This ensures that the --into target is correctly resolved and considered during the merge operation.

Fixes CLI-1AF

Comment @sentry <feedback> on this PR to have Autofix iterate on the changes.

@github-actions github-actions Bot added the risk: high PR risk score: high label Jul 15, 2026
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-28 10:30 UTC

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit bccec76. Configure here.

Comment thread src/commands/issue/merge.ts Outdated
@BYK BYK added the jared Trigger the Jared agent to work on stuff label Jul 24, 2026

@jared-outpost jared-outpost 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.

This change is regressing correct behavior — I'd recommend closing it rather than merging.

The premise doesn't match --into's design. The flag's own brief says it "must match one of the provided IDs": --into selects which of the provided issues becomes the canonical parent. It is not a way to add another issue to the merge set. So sentry issue merge CLI-A CLI-B --into CLI-C (with CLI-C not among the positionals) is meant to error — the fix is merge CLI-A CLI-B CLI-C --into CLI-C.

It breaks 4 existing tests in test/commands/issue/merge.func.test.ts (this is the failing Unit Tests check):

  • --into rejects a value that doesn't match any provided issue — this test intentionally asserts that --into CLI-XYZ with positionals CLI-A CLI-B is rejected. This PR appends CLI-XYZ into effectiveArgs, so it's no longer rejected.
  • 1 positional + --into same issue triggers dedupe guardmerge CLI-A --into CLI-A should reach the clearer "at least 2 distinct issues" error. The !args.includes(flags.into) guard suppresses the append here, so it falls back to the generic "needs at least 2 issue IDs" message (this is also what Bugbot flagged above).
  • --into swallows ResolutionError as clean not-found and fast-path matches short IDs case-insensitively — both break because args.includes(flags.into) is a strict string compare that misses case/alias/org-qualified forms, changing how many issues get resolved.

main already handles the single-issue convenience form correctly with args.length === 1 && flags.into ? [...args, flags.into] : args, and it also correctly produces the distinct-issues error for merge CLI-A --into CLI-A. The change here (flags.into && !args.includes(flags.into)) is what introduces the regressions.

If the underlying Sentry issue (CLI-1AF) was a user running merge A B --into C and getting a confusing error, the right fix would be improving that error message to suggest adding C as a positional — not changing --into to silently pull in an unlisted issue. Closing this in favor of that approach.

@BYK

BYK commented Jul 27, 2026

Copy link
Copy Markdown
Member

Jared, we want this new behavior so let's get the build fixed

@MathurAditya724

Copy link
Copy Markdown
Member

Jared, listen to @BYK 😅

sentry Bot and others added 2 commits July 28, 2026 10:09
--into now designates an issue that always participates in the merge (as
the preferred parent), even when it is not one of the positional args.
Previously merge CLI-A CLI-B --into CLI-C dropped CLI-C whenever 2+
positionals were given, so orderForMerge could not find it and threw a
'did not match any of the provided issues' error (CLI-1AF).

The target is appended to the arg list unconditionally; duplicate forms
of the same issue (positional + --into) collapse via numeric-ID dedupe
in resolveAllIssues. Updated the merge tests to cover the new semantics.

Fixes CLI-1AF
@jared-outpost
jared-outpost Bot force-pushed the seer/fix-issue-merge-into-flag branch from bccec76 to 512bf6a Compare July 28, 2026 10:16
@jared-outpost

jared-outpost Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Done. The build was failing on test/commands/issue/merge.func.test.ts — those tests encoded the old semantics where --into had to match one of the positionals.

I reworked the change to match the behavior @BYK wants: --into now always designates an issue that participates in the merge (as the preferred parent), so sentry issue merge CLI-A CLI-B --into CLI-C merges all three with CLI-C as parent. Duplicate forms of the same issue (positional + --into) collapse via numeric-ID dedupe in resolveAllIssues rather than being sent to the API twice.

Also rebased onto main (was 24 commits behind) and updated the affected tests. Pushed as 512bf6a.

@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 5492 uncovered lines.
❌ Project coverage is 81.5%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    81.56%    81.50%    -0.06%
==========================================
  Files          428       428         —
  Lines        29661     29694       +33
  Branches     19429     19435        +6
==========================================
+ Hits         24194     24202        +8
- Misses        5467      5492       +25
- Partials      2024      2029        +5

Generated by Codecov Action

@BYK
BYK merged commit 7d0e8c4 into main Jul 28, 2026
32 checks passed
@BYK
BYK deleted the seer/fix-issue-merge-into-flag branch July 28, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jared Trigger the Jared agent to work on stuff risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants