fix(issue): resolve link verb via /api/issueLinkTypes (YT-12) #56

Merged
David merged 1 commit from fix/issue-link-default-type-YT-12 into main 2026-05-24 17:48:04 +02:00
Owner

Summary

Fixes YT-12. yt issue link <SOURCE> <TARGET> (default --type relates) was emitting relates <TARGET> as the YouTrack command body, which the server rejected with Unknown command: relates <id> because the command-language verb for the Relates link type is relates to, not relates. Same misalignment exists for every standard link type whose display name differs from its sourceToTarget verb (Depend -> depends on, Subtask -> is subtask of, etc.).

run_link_inner now fetches /api/issueLinkTypes and resolves the user-supplied --type value to the correct verb before building the /api/commands body. The short form (relates, depends) maps to sourceToTarget; the already-qualified long form (relates to, is required for) passes through, with casing normalized to whatever the server returned so the command parser does not choke on RELATES TO. Unknown link-type names now surface a clear error listing the available verbs instead of bubbling up an HTTP 400 from the server. --dry-run previews the corrected command body so users can see what would be sent without mutating anything.

Test plan

  • cargo fmt --check, cargo clippy, cargo build, cargo test (via just pre-commit) all green; 299 unit tests pass including 9 new resolve_link_verb cases covering: short-name -> source-to-target mapping, case-insensitive name match, already-qualified verb pass-through, target-to-source pass-through, depends on round-trip, uppercase normalization, unknown-type error message lists available verbs, empty input rejection, and fallback to lowercased name when sourceToTarget is missing.
  • Live smoke against niceguyit.myjetbrains.com: yt issue link YT-11 MK-16 (default --type relates) and yt issue link --type "depends on" YT-11 MK-16 both succeed.
  • Live smoke: yt --dry-run issue link YT-11 MK-16 prints the corrected command body relates to MK-16 without hitting /api/commands.

#YT-12

## Summary Fixes YT-12. `yt issue link <SOURCE> <TARGET>` (default `--type relates`) was emitting `relates <TARGET>` as the YouTrack command body, which the server rejected with `Unknown command: relates <id>` because the command-language verb for the `Relates` link type is `relates to`, not `relates`. Same misalignment exists for every standard link type whose display `name` differs from its `sourceToTarget` verb (`Depend` -> `depends on`, `Subtask` -> `is subtask of`, etc.). `run_link_inner` now fetches `/api/issueLinkTypes` and resolves the user-supplied `--type` value to the correct verb before building the `/api/commands` body. The short form (`relates`, `depends`) maps to `sourceToTarget`; the already-qualified long form (`relates to`, `is required for`) passes through, with casing normalized to whatever the server returned so the command parser does not choke on `RELATES TO`. Unknown link-type names now surface a clear error listing the available verbs instead of bubbling up an HTTP 400 from the server. `--dry-run` previews the corrected command body so users can see what would be sent without mutating anything. ## Test plan - [x] `cargo fmt --check`, `cargo clippy`, `cargo build`, `cargo test` (via `just pre-commit`) all green; 299 unit tests pass including 9 new `resolve_link_verb` cases covering: short-name -> source-to-target mapping, case-insensitive name match, already-qualified verb pass-through, target-to-source pass-through, `depends on` round-trip, uppercase normalization, unknown-type error message lists available verbs, empty input rejection, and fallback to lowercased name when `sourceToTarget` is missing. - [ ] Live smoke against `niceguyit.myjetbrains.com`: `yt issue link YT-11 MK-16` (default `--type relates`) and `yt issue link --type "depends on" YT-11 MK-16` both succeed. - [ ] Live smoke: `yt --dry-run issue link YT-11 MK-16` prints the corrected command body `relates to MK-16` without hitting `/api/commands`. #YT-12
fix(issue): resolve link verb via /api/issueLinkTypes (YT-12)
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 32s
Create release / Create release from merged PR (pull_request) Has been skipped
4df5dac695
`yt issue link <SOURCE> <TARGET>` was emitting `<type-name> <TARGET>` as the YouTrack command body, which only worked when the display name happened to equal the command-language verb. For the default `--type relates` it produced `relates <TARGET>` and the server rejected the request as "Unknown command: relates <id>". Same shape for `Depend` -> `depends` (needs `depends on`), `Subtask` -> `subtask` (needs `is subtask of`), etc.

The fix looks the link type up on `/api/issueLinkTypes` (which already exposes `sourceToTarget` / `targetToSource` strings) and substitutes the correct verb. `--type relates` issues `relates to <TARGET>`. A user who passes the long form (`--type "relates to"`) gets it back unchanged, with casing normalized to whatever the server returned. Unknown link types now surface a clear error listing the available verbs instead of bubbling up an HTTP 400. `--dry-run` previews the corrected command body so users can see what would be sent.

#YT-12 State Done
David merged commit 55860b099d into main 2026-05-24 17:48:04 +02:00
David deleted branch fix/issue-link-default-type-YT-12 2026-05-24 17:48:04 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pandoras-box/youtrack-cli!56
No description provided.