Skip to content

fix: make optional fields in Licence struct and fix RateLimit response structure#131

Merged
23prime merged 5 commits intomainfrom
feature/129-130-fix-licence-rate-limit-deserialization
Mar 23, 2026
Merged

fix: make optional fields in Licence struct and fix RateLimit response structure#131
23prime merged 5 commits intomainfrom
feature/129-130-fix-licence-rate-limit-deserialization

Conversation

@23prime
Copy link
Copy Markdown
Owner

@23prime 23prime commented Mar 23, 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

  • bl space licence failed with missing field 'startDate' / missing field 'storageUsage' because the real API omits these fields
  • bl rate-limit failed with missing field 'limit' because the struct expected a flat rateLimit.limit shape, but the real API returns four categories (read, update, search, icon)

Reason for change

Struct definitions were written based on assumed API shapes rather than verified against the real Backlog API. Revealed by the new smoke-test script.

Changes

  • src/api/licence.rs: make start_date, storage_limit, storage_usage Option; add test for response without startDate/storageUsage
  • src/cmd/space/licence.rs: handle Option fields in format_licence_text; add tests
  • src/api/rate_limit.rs: introduce RateLimitCategory; restructure RateLimitInfo with read/update/search/icon fields; update tests
  • src/cmd/rate_limit.rs: update format_rate_limit_text to show all four categories; update tests
  • smoke-test.sh: new smoke-test script
  • .cspell/dicts/project.txt, .gitignore: housekeeping for spell-check

Notes

Closes #129
Closes #130

…e structure

- Licence: make start_date, storage_limit, storage_usage Option to handle
  real API responses that omit these fields
- RateLimit: restructure RateLimitInfo to hold four categories (read, update,
  search, icon) matching the actual nested API response shape

Closes #129
Closes #130
Copilot AI review requested due to automatic review settings March 23, 2026 12:33
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 23, 2026

Warning

Rate limit exceeded

@23prime has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 46 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: a5a94564-b55c-40cb-8975-6d7e1f186623

📥 Commits

Reviewing files that changed from the base of the PR and between bfba5cf and e3fa860.

📒 Files selected for processing (2)
  • mise.toml
  • smoke-test.sh
📝 Walkthrough

Walkthrough

Make Licence fields optional and reshape RateLimit into per-category objects; update CLI formatting and tests accordingly. Add a read-only smoke-test script, extend spell-check dictionary, and ignore its result file; update docs (EN/JA) for the changed outputs.

Changes

Cohort / File(s) Summary
Configuration & Dictionary
.cspell/dicts/project.txt, .gitignore
Added five spell-check entries (gantt, sattg, varname, CMTS, DOTS) and added smoke-test-result.txt to .gitignore.
Smoke Test Script
smoke-test.sh
New executable Bash script that runs many read-only bl --json smoke tests against a real Backlog space, captures IDs via jq, tracks PASS/FAIL, skips dependent commands when IDs are missing, and exits nonzero if any executed command failed.
API Data Models
src/api/licence.rs, src/api/rate_limit.rs
Licence fields start_date, storage_limit, storage_usage changed to Option<...>; RateLimit restructured: introduced RateLimitCategory and RateLimitInfo now holds read, update, search, and optional icon. Tests updated and new null-case tests added.
CLI Formatting & Tests
src/cmd/rate_limit.rs, src/cmd/space/licence.rs
Updated output formatting to show RateLimit per-category (Read/Update/Search and optional Icon) and to render Licence fallback text for missing fields ((not set), (unknown)); adjusted fixtures and tests.
Documentation
website/docs/commands.md, website/i18n/ja/.../commands.md
Updated bl space licence and bl rate-limit examples and notes to reflect nullable licence fields and per-category rate-limit output; added note about Icon appearing only when present.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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 clearly summarizes the main changes: making optional fields in Licence and fixing RateLimit response structure.
Description check ✅ Passed The description is directly related to the changeset, explaining the deserialization issues discovered by smoke tests and detailing the fixes applied.
Linked Issues check ✅ Passed All code changes fully address the objectives from linked issues #129 and #130: Licence fields made optional with tests, RateLimit restructured with categories, and formatting updated accordingly.
Out of Scope Changes check ✅ Passed All changes are directly related to resolving issues #129 and #130; smoke-test.sh, spell-check dictionary, and documentation updates support the core fixes.

✏️ 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/129-130-fix-licence-rate-limit-deserialization

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
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

Fixes deserialization failures for bl space licence and bl rate-limit by aligning Rust structs with the actual Backlog API response shapes, plus adds a new smoke-test script to validate read-only commands against a real space.

Changes:

  • Make Licence fields optional where the API may omit them, and update CLI formatting + tests accordingly.
  • Reshape rate-limit models into per-category limits (read/update/search/icon) and update CLI output + tests.
  • Add smoke-test.sh to exercise many read-only CLI commands; minor repo housekeeping updates.

Reviewed changes

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

Show a summary per file
File Description
src/api/licence.rs Makes licence response fields optional and adds coverage for omitted fields.
src/cmd/space/licence.rs Formats optional licence fields safely; extends unit tests.
src/api/rate_limit.rs Updates rate-limit response model to match nested category structure; updates tests.
src/cmd/rate_limit.rs Prints rate-limit across categories; updates unit tests.
smoke-test.sh Adds a script to run many read-only bl commands against a real space.
.gitignore Ignores a smoke test result file.
.cspell/dicts/project.txt Adds project-specific words used by the new script.

Copy link
Copy Markdown

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@smoke-test.sh`:
- Around line 16-21: Replace the hardcoded /tmp/bl_out with a secure temporary
file created via mktemp and ensure it is removed on script exit: create a temp
file variable (e.g., TMP_OUT=$(mktemp)) before running the command that uses
"$BL" and redirect stdout/stderr to that file, update the success/fail branches
that reference /tmp/bl_out to use the temp variable, and add a trap 'rm -f
"$TMP_OUT"' on EXIT to guarantee cleanup; apply the same change to the second
occurrence that prints or cats the temp output, and make sure PASS and label
usage remains unchanged.
- Around line 28-37: The run_capture block uses eval to assign command output
into a variable (eval "$varname"='$(cat /tmp/bl_out)') which allows command
injection; replace the eval usage by reading the output file into the named
variable safely with printf -v and avoid word-splitting/expansion (e.g., printf
-v "$varname" '%s' "$(cat /tmp/bl_out)") and similarly set the empty-case with
printf -v "$varname" '%s' '' instead of eval; also consider making the temp file
unique (e.g., include $$ or use mktemp) to avoid collisions when locating
/tmp/bl_out, and keep references to BL and SPACE_KEY intact.
🪄 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: b88e061c-df2d-4db1-aa6f-a72bb5bd42bc

📥 Commits

Reviewing files that changed from the base of the PR and between 0a72df1 and 030afd9.

📒 Files selected for processing (7)
  • .cspell/dicts/project.txt
  • .gitignore
  • smoke-test.sh
  • src/api/licence.rs
  • src/api/rate_limit.rs
  • src/cmd/rate_limit.rs
  • src/cmd/space/licence.rs

23prime added 2 commits March 23, 2026 22:06
Addresses review comment: use mktemp to avoid /tmp/bl_out clobbering/races,
and printf -v instead of eval to avoid potential code execution from
captured output.
- rate-limit: show all four categories (read/update/search/icon) in example
- space licence: add note and example for plans where startDate/storageUsage
  are absent from the API response
Copy link
Copy Markdown

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

🧹 Nitpick comments (1)
smoke-test.sh (1)

41-41: Minor inconsistency: add '%s' format specifier for consistency.

Line 36 uses printf -v "$varname" '%s' "$output" with the format specifier, but line 41 omits it. While functionally equivalent for setting an empty string, adding the format specifier improves consistency.

Suggested fix
-        printf -v "$varname" ''
+        printf -v "$varname" '%s' ''
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@smoke-test.sh` at line 41, Replace the call that sets an empty value with
printf -v "$varname" '%s' '' to match the earlier usage (printf -v "$varname"
'%s' "$output"); update the statement using printf -v "$varname" '' so it
includes the '%s' format specifier for consistency around the variable
assignment of "$varname".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@smoke-test.sh`:
- Line 41: Replace the call that sets an empty value with printf -v "$varname"
'%s' '' to match the earlier usage (printf -v "$varname" '%s' "$output"); update
the statement using printf -v "$varname" '' so it includes the '%s' format
specifier for consistency around the variable assignment of "$varname".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 036b1824-a770-43b0-a784-e201fce891fb

📥 Commits

Reviewing files that changed from the base of the PR and between 030afd9 and bfba5cf.

📒 Files selected for processing (3)
  • smoke-test.sh
  • website/docs/commands.md
  • website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md
✅ Files skipped from review due to trivial changes (2)
  • website/docs/commands.md
  • website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md

@23prime 23prime merged commit 0a4cca5 into main Mar 23, 2026
8 checks passed
@23prime 23prime deleted the feature/129-130-fix-licence-rate-limit-deserialization branch March 23, 2026 14:02
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.

fix: rate-limit deserialization fails due to incorrect response structure fix: space licence deserialization fails when startDate is absent

2 participants