fix(attachment): download file bytes, not the YouTrack SPA #70

Merged
David merged 1 commit from fix/attachment-get-spa-html-YT-24 into main 2026-06-13 13:37:27 +02:00
Owner

yt issue attachment get wrote the YouTrack web SPA shell (the manager index.html) to the output path instead of the attachment bytes. The attachment url field is a root-relative path that, on instances served under a context path (e.g. https://host/youtrack), already carries that context. The old code concatenated it onto the configured base URL, duplicating the context (/youtrack/youtrack/...); that path matches no API route, so YouTrack returns its SPA shell with HTTP 200 and the body was saved verbatim.

Resolve attachment URLs against the instance origin via resolve_youtrack_url: absolute URLs pass through, root-relative paths that already include the context join to the origin (no duplication), and context-relative paths get the context prepended. The transport now also surfaces the response Content-Type, and download_attachment rejects any HTML response (by content type, or by an HTML body marker when no type is sent) rather than writing the app shell to disk.

Tests: unit coverage for URL resolution across context/no-context/absolute/trailing-slash cases and the HTML heuristic, an add-then-get round-trip asserting byte equality (size + sha256), and a guard test that an SPA text/html response fails loudly.

#YT-24

`yt issue attachment get` wrote the YouTrack web SPA shell (the manager `index.html`) to the output path instead of the attachment bytes. The attachment `url` field is a root-relative path that, on instances served under a context path (e.g. `https://host/youtrack`), already carries that context. The old code concatenated it onto the configured base URL, duplicating the context (`/youtrack/youtrack/...`); that path matches no API route, so YouTrack returns its SPA shell with HTTP 200 and the body was saved verbatim. Resolve attachment URLs against the instance origin via `resolve_youtrack_url`: absolute URLs pass through, root-relative paths that already include the context join to the origin (no duplication), and context-relative paths get the context prepended. The transport now also surfaces the response `Content-Type`, and `download_attachment` rejects any HTML response (by content type, or by an HTML body marker when no type is sent) rather than writing the app shell to disk. Tests: unit coverage for URL resolution across context/no-context/absolute/trailing-slash cases and the HTML heuristic, an add-then-get round-trip asserting byte equality (size + sha256), and a guard test that an SPA `text/html` response fails loudly. #YT-24
fix(attachment): download file bytes, not the YouTrack SPA
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 18s
Create release / Create release from merged PR (pull_request) Has been skipped
1841e8c7bf
`yt issue attachment get` wrote the YouTrack web SPA shell (the manager `index.html`) to the output path instead of the attachment bytes. The attachment `url` field is a root-relative path that, on instances served under a context path (e.g. `https://host/youtrack`), already carries that context. The old code concatenated it onto the configured base URL, duplicating the context (`/youtrack/youtrack/...`); that path matches no API route, so YouTrack returns its SPA shell with HTTP 200 and the body was saved verbatim.

Resolve attachment URLs against the instance origin via `resolve_youtrack_url`: absolute URLs pass through, root-relative paths that already include the context join to the origin (no duplication), and context-relative paths get the context prepended. The transport now also surfaces the response `Content-Type`, and `download_attachment` rejects any HTML response (by content type, or by an HTML body marker when no type is sent) rather than writing the app shell to disk.

Tests: unit coverage for URL resolution across context/no-context/absolute/trailing-slash cases and the HTML heuristic, an add-then-get round-trip asserting byte equality (size + sha256), and a guard test that an SPA `text/html` response fails loudly.

#YT-24
David merged commit 75d070e5ee into main 2026-06-13 13:37:27 +02:00
David deleted branch fix/attachment-get-spa-html-YT-24 2026-06-13 13:37:27 +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!70
No description provided.