Skip to content

refactor: exit 64 for ambiguous partial_match input (#237)#239

Merged
Zious11 merged 1 commit intodevelopfrom
refactor/ambiguous-exit-code-237
Apr 21, 2026
Merged

refactor: exit 64 for ambiguous partial_match input (#237)#239
Zious11 merged 1 commit intodevelopfrom
refactor/ambiguous-exit-code-237

Conversation

@Zious11
Copy link
Copy Markdown
Owner

@Zious11 Zious11 commented Apr 21, 2026

Summary

  • Unify exit codes across the four partial_match handlers: all ambiguous-substring errors now exit 64 (JrError::UserError).
  • Before: move / link / unlink used anyhow::bail! → exit 1. list --status already used UserError → exit 64.
  • After: all four use UserError → exit 64.
  • Error text unchanged byte-for-byte — scripts/greps looking for "Ambiguous transition" or "Ambiguous link type" keep working.

Why it matters

An AI agent or shell pipeline checking \$? == 64 for "bad user input" previously missed move/link/unlink ambiguity and treated them as transient errors. Now the contract is consistent.

Changes

  • src/cli/issue/workflow.rs:157bail!JrError::UserError (Ambiguous transition, --no-input)
  • src/cli/issue/links.rs:67 — same (link, Ambiguous link type)
  • src/cli/issue/links.rs:136 — same (unlink, Ambiguous link type)
  • tests/issue_commands.rs — flip pinned Some(1)Some(64) for the two tests added in PR test: integration tests for partial_match substring rejection (#193) #238, remove stale "currently exits 1" comments.

Scope notes

Test plan

  • cargo fmt --all -- --check clean
  • cargo clippy --all-targets -- -D warnings clean
  • cargo test — 803 passed, 0 failed
  • The two flipped tests pass with Some(64):
    • test_move_single_substring_rejected_no_input
    • test_link_single_substring_rejected_no_input

Closes #237

issue move, issue link, and issue unlink reported ambiguous-substring
errors via anyhow::bail! which doesn't inject a JrError into the cause
chain, so main.rs fell back to exit 1. issue list --status already used
JrError::UserError (exit 64) for the same failure class, producing an
inconsistency that broke scripts keying off $? == 64.

Change the three Ambiguous + no_input branches to return
JrError::UserError so all four handlers surface exit 64 uniformly.
Error-message strings are byte-identical — no script-visible wording
changes. Updates the two tests added in PR #238 to pin Some(64).

Closes #237
Copy link
Copy Markdown

Copilot AI left a comment

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 standardizes exit behavior for partial_match ambiguity errors across issue move, issue link, and issue unlink so they consistently surface as JrError::UserError (exit code 64) rather than anyhow::bail! (exit code 1), aligning with existing behavior in issue list --status.

Changes:

  • Switch ambiguous-substring --no-input branches from anyhow::bail! to JrError::UserError(...) in move/link/unlink handlers.
  • Update integration tests to assert exit code 64 for the ambiguous-substring cases in move and link.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/cli/issue/workflow.rs Return JrError::UserError on ambiguous transition under --no-input to produce exit 64.
src/cli/issue/links.rs Return JrError::UserError on ambiguous link type under --no-input for both link and unlink.
tests/issue_commands.rs Update pinned exit-code assertions from 1 to 64 for the relevant integration tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Zious11 Zious11 merged commit 8d89ba2 into develop Apr 21, 2026
11 checks passed
@Zious11 Zious11 deleted the refactor/ambiguous-exit-code-237 branch April 21, 2026 03:27
Zious11 added a commit that referenced this pull request Apr 21, 2026
#236) (#241)

Adds handler-level (or library-level where plumbing outweighs signal)
coverage for three more partial_match callers identified in #236:

  - issue unlink  (tests/issue_commands.rs — binary test, exit 64)
  - queue resolve (tests/queue.rs — library test on resolve_queue_by_name)
  - assets schema (tests/assets.rs — binary test, --schema ambiguity)

Each uses a single-hit substring input (per the #193 regression
surface) and asserts the Ambiguous branch fires with the expected
disambiguation message. The binary tests pin exit 64 to complement
PR #239's bail!→UserError unification. The unlink test mounts no
DELETE mock so wiremock 404s any state-change attempt; the assets
schema test mounts both objecttypes/flat endpoints with .expect(0)
to lock the short-circuit.

The remaining 5 call sites from #236 (helpers.rs team/user/asset,
assets search --status, assets schema <type_name>) need CMDB/user/
team plumbing or await a parallel bail!→UserError refactor of
helpers.rs. Tracked in #240.

Refs #236
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.

refactor: unify exit codes for ambiguous input — move/link currently exit 1, list exits 64

2 participants