Skip to content

fix: get_cats reports "*" default-category sentinel - #80

Closed
thedancingdeveloper wants to merge 1 commit into
mainfrom
fix/73-get-cats-sentinel
Closed

fix: get_cats reports "*" default-category sentinel#80
thedancingdeveloper wants to merge 1 commit into
mainfrom
fix/73-get-cats-sentinel

Conversation

@thedancingdeveloper

Copy link
Copy Markdown
Collaborator

Summary

Fixes #73: mode=get_cats should report the default category as the literal string "*", not "Default".

Verified against sabnzbd/sabnzbd@5.1.x:

# sabnzbd/api.py:792-793
def _api_get_cats(name, kwargs):
    return report(keyword="categories", data=list_cats(False))

# sabnzbd/api.py:2090-2098
def list_cats(default: bool = True) -> list[str]:
    lst = [cat["name"] for cat in config.get_ordered_categories()]
    if default:
        lst.remove("*")
        lst.insert(0, "Default")
    return lst

_api_get_cats explicitly calls list_cats(False), so the real response is {"categories": ["*", "movies", "tv", ...]} — the "*"→"Default" substitution only happens for the internal config UI.

Impact

Likely related to #65: a client that specifically recognizes "*" as the default-category sentinel (rather than treating the array as opaque display names) wouldn't find it in RustNZB's response.

Fix

handle_get_cats now emits "*" for the default category. Since RustNZB's own category model still names it "Default" internally, added sab_resolve_category() to translate "*" back to "Default" wherever a client-supplied cat value is applied (addfile, addurl, change_cat), keeping both directions of the boundary translation consistent.

Test plan

  • cargo test -p nzb-web — added get_cats_reports_default_category_as_sabnzbd_sentinel and change_cat_accepts_sabnzbd_default_sentinel.
  • cargo clippy -p nzb-web --all-targets — clean.
  • Full nzb-web test suite passes.

🤖 Generated with Claude Code

Real SABnzbd's get_cats calls list_cats(default=False), which leaves
the default category's config-internal name "*" untouched -- the
"*" -> "Default" substitution only happens for the config UI
(default=True). RustNZB returned the display string "Default"
instead, which a client that specifically recognizes "*" as the
default-category sentinel wouldn't find.

Adds sab_resolve_category() to translate "*" back to RustNZB's
internal "Default" category name wherever a client-supplied cat
value is applied (addfile, addurl, change_cat), so both directions
of the boundary translation stay consistent.
@thedancingdeveloper

Copy link
Copy Markdown
Collaborator Author

Superseded — this change landed via #84, which stacked all of #71-#77's fixes together and was squash-merged to save on redundant CI runs. Closing without merging to avoid re-applying the same diff.

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.

SABnzbd compat: get_cats returns "Default" instead of the real "*" sentinel

1 participant