Skip to content

feat: implement bl space image (GET /api/v2/space/image)#122

Merged
23prime merged 4 commits intomainfrom
feature/118-space-image
Mar 22, 2026
Merged

feat: implement bl space image (GET /api/v2/space/image)#122
23prime merged 4 commits intomainfrom
feature/118-space-image

Conversation

@23prime
Copy link
Owner

@23prime 23prime commented Mar 22, 2026

Checklist

  • Target branch is main
  • Status checks are passing
  • Documentation updated if user-visible behavior changed (website/docs/, website/i18n/ja/, README.md)

Summary

  • Add bl space image command to download the space icon image
  • Supports --output <path> (-o) to specify the save path; defaults to the server-provided filename

Reason for change

Implements the remaining GET /api/v2/space/image endpoint so all published Backlog API v2 endpoints in the Space category are covered.

Changes

  • src/api/space.rs — add download_space_image()
  • src/api/mod.rs — add download_space_image to BacklogApi trait and impl BacklogApi for BacklogClient
  • src/cmd/space/image.rs — new command with image() / image_with() and unit tests
  • src/cmd/space/mod.rs — re-export SpaceImageArgs and image
  • src/main.rs — add SpaceCommands::Image variant and dispatch
  • website/docs/commands.md, website/i18n/ja/.../commands.md — add command docs and mark as implemented

Notes

Closes #118

Copilot AI review requested due to automatic review settings March 22, 2026 12:09
@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

Warning

Rate limit exceeded

@23prime has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 24 minutes and 18 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d055524d-45bc-4622-aa57-743dfbd68cbb

📥 Commits

Reviewing files that changed from the base of the PR and between 2bacf68 and f13d9ac.

📒 Files selected for processing (3)
  • src/cmd/space/image.rs
  • website/docs/commands.md
  • website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md
📝 Walkthrough

Walkthrough

Adds a new CLI command bl space image to download the space icon via GET /api/v2/space/image, extends the BacklogApi trait and BacklogClient with download_space_image(), implements saving the returned bytes to disk (optional --output) and updates English/Japanese docs.

Changes

Cohort / File(s) Summary
API Layer
src/api/mod.rs, src/api/space.rs
Added fn download_space_image(&self) -> Result<(Vec<u8>, String)> to BacklogApi and implemented it on BacklogClient to call the /space/image download endpoint returning (bytes, filename).
CLI Command Implementation
src/cmd/space/image.rs
New command module: SpaceImageArgs, image() entry, image_with() uses download_space_image(), determines output path (explicit or default), writes bytes to disk, prints success, includes unit tests for save/default/failure cases.
CLI Integration
src/cmd/space/mod.rs, src/main.rs
Registered and re-exported image submodule; added SpaceCommands::Image { output: Option<PathBuf> } and dispatch handling to invoke the new command.
Documentation
website/docs/commands.md, website/i18n/ja/.../commands.md
Added bl space image usage/examples and marked GET /api/v2/space/image as implemented in command coverage tables.

Sequence Diagram

sequenceDiagram
    participant User as User
    participant CLI as "CLI (main.rs)"
    participant Handler as "space/image.rs"
    participant API as "BacklogClient"
    participant Server as "Backlog Server"
    participant FS as "File System"

    User->>CLI: bl space image [--output path]
    CLI->>Handler: image(&SpaceImageArgs)
    Handler->>API: download_space_image()
    API->>Server: GET /api/v2/space/image
    Server->>API: returns (bytes, filename)
    API->>Handler: Result<(Vec<u8>, String)>
    Handler->>Handler: determine output path (arg or default)
    Handler->>FS: write(path, bytes)
    FS-->>Handler: write result
    Handler->>User: print "Saved: <path> (<n> bytes)"
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: implement bl space image (GET /api/v2/space/image)' clearly and concisely summarizes the main change: implementing a new CLI command to download space images.
Description check ✅ Passed The description is well-structured with a checklist, summary, motivation, and detailed change list that clearly relates to implementing the bl space image command.
Linked Issues check ✅ Passed The PR implements all requirements from issue #118: API endpoint in src/api/space.rs, CLI command in src/cmd/space/image.rs with --output option, default filename fallback, and documentation updates for both English and Japanese docs.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the bl space image command. No unrelated modifications are present; changes are limited to API, CLI, and documentation for the new feature.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feature/118-space-image

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 and usage tips.

Copy link

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

Adds support for Backlog API v2 GET /api/v2/space/image and exposes it via a new bl space image CLI subcommand to download the space icon image, with corresponding command documentation updates.

Changes:

  • Implement download_space_image() in the API layer and expose it via the BacklogApi trait.
  • Add bl space image command (with --output/-o) plus unit tests for the command behavior.
  • Update English/Japanese command docs and mark the endpoint as implemented in the coverage tables.

Reviewed changes

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

Show a summary per file
File Description
src/api/space.rs Adds a BacklogClient::download_space_image() wrapper over the shared download helper.
src/api/mod.rs Extends BacklogApi with download_space_image and wires the client implementation.
src/cmd/space/image.rs New command implementation to download and write the space icon image, with unit tests.
src/cmd/space/mod.rs Registers/re-exports the new space image command and args.
src/main.rs Adds SpaceCommands::Image clap variant and dispatches to the new command.
website/docs/commands.md Documents bl space image and marks the endpoint as implemented.
website/i18n/ja/.../commands.md Japanese docs for bl space image and endpoint coverage update.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/api/space.rs (1)

26-27: Add a direct API-layer test for /space/image.

The command tests are mock-based, so this literal path and its (bytes, filename) result are currently unpinned. A small httpmock case here would catch route typos and filename/body regressions.

🧪 Suggested test
+    #[test]
+    fn download_space_image_returns_bytes_and_filename() {
+        let server = MockServer::start();
+        server.mock(|when, then| {
+            when.method(GET).path("/space/image");
+            then.status(200)
+                .header(
+                    "content-disposition",
+                    r#"attachment; filename="space_image.png""#,
+                )
+                .body("png");
+        });
+
+        let client = BacklogClient::new_with(&server.base_url(), "test-key").unwrap();
+        let (bytes, filename) = client.download_space_image().unwrap();
+
+        assert_eq!(filename, "space_image.png");
+        assert_eq!(bytes, b"png".to_vec());
+    }

As per coding guidelines, api/ layer tests should use httpmock to spin up a local HTTP server and construct BacklogClient::new_with(base_url, api_key) instead of calling BacklogClient::from_config().

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/api/space.rs` around lines 26 - 27, Add a new api-layer test that spins
up an httpmock server for the "/space/image" route and asserts the (Vec<u8>,
filename) tuple returned by BacklogClient::download_space_image; specifically,
configure the mock to respond with the expected binary body and
Content-Disposition (or filename) header, construct the client with
BacklogClient::new_with(base_url, api_key) (not from_config), call
download_space_image (which delegates to download), and assert the returned
bytes and filename match the mock values to catch path/filename regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@website/docs/commands.md`:
- Around line 154-166: Update the `bl space image` docs to explicitly state the
response is binary image data and that the `--output`/`-o` flag controls the
destination filename; describe the default behavior when omitted (write to the
current directory with a default name such as space_image.png and print a
"Saved: ..." message) and add the same note to the Japanese translation page;
target the `bl space image` section and mention the `--output`/`-o` flags and
the example "Saved: space_image.png" output so readers understand where the file
goes and what to expect.

---

Nitpick comments:
In `@src/api/space.rs`:
- Around line 26-27: Add a new api-layer test that spins up an httpmock server
for the "/space/image" route and asserts the (Vec<u8>, filename) tuple returned
by BacklogClient::download_space_image; specifically, configure the mock to
respond with the expected binary body and Content-Disposition (or filename)
header, construct the client with BacklogClient::new_with(base_url, api_key)
(not from_config), call download_space_image (which delegates to download), and
assert the returned bytes and filename match the mock values to catch
path/filename regressions.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 50f22670-6a72-4834-bb00-19d9c4645f86

📥 Commits

Reviewing files that changed from the base of the PR and between 5981a5e and 317e8e6.

📒 Files selected for processing (7)
  • src/api/mod.rs
  • src/api/space.rs
  • src/cmd/space/image.rs
  • src/cmd/space/mod.rs
  • src/main.rs
  • website/docs/commands.md
  • website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md

23prime added 2 commits March 22, 2026 22:16
…eric

Addresses review comment: add explicit check for missing/placeholder filenames ("attachment") and substitute domain-specific default
@23prime
Copy link
Owner Author

23prime commented Mar 22, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In `@src/cmd/space/image.rs`:
- Around line 33-38: The fallback in function default_output_path currently only
treats the exact string "attachment" as a placeholder; update the condition to
also detect common placeholder variants (e.g., "attachment.png", "attachment-1",
etc.) by replacing the equality check with a starts_with check (e.g.,
filename.is_empty() || filename.starts_with("attachment")), so the effective
name becomes "space_image" for those cases; keep the rest of default_output_path
unchanged.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3b4dc9cf-e215-4537-ba0f-ff583f64de72

📥 Commits

Reviewing files that changed from the base of the PR and between 317e8e6 and 2bacf68.

📒 Files selected for processing (2)
  • src/cmd/space/image.rs
  • src/main.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main.rs

…_path

Addresses review comment: fallback was too narrow — only exact "attachment" was handled
@23prime 23prime merged commit 28bf878 into main Mar 22, 2026
8 checks passed
@23prime 23prime deleted the feature/118-space-image branch March 22, 2026 13:46
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.

feat: implement bl space image (GET /api/v2/space/image)

2 participants