Skip to content

fix(subsonic): percent-encode the username in request URLs - #855

Merged
LargeModGames merged 1 commit into
LargeModGames:mainfrom
jadhavgaurav:fix/subsonic-username-encoding
Oct 15, 2026
Merged

LargeModGames merged 1 commit into
LargeModGames:mainfrom
jadhavgaurav:fix/subsonic-username-encoding

Conversation

@jadhavgaurav

@jadhavgaurav jadhavgaurav commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

SubsonicSource::endpoint_url put self.username into the ?u= query value without encoding it, so a username with +, &, #, %, = or a space reached the server changed or cut off, and every request failed with Subsonic error 40. The username now goes through the existing url_encode helper, as stream_url already does for the track id. url_encode, base_url, view, compute_token and generate_salt are untouched, and self.username is not used in any other URL.

Adds three tests in the subsonic tests module (an encoded mixed username, one with #, % and =, and a plain name that must stay unchanged) and a CHANGELOG.md Fixed line.

Fixes #814

Testing

AI assistance: partially generated with Claude Code; I read the whole diff and ran every command below locally.

  • The new tests fail without the fix: with only the endpoint_url change reverted, a_username_with_query_characters_is_percent_encoded fails on the u= assert; with the fix it passes.
  • cargo test --no-default-features --features telemetry,tui,subsonic a_username_with_query: 1 passed
  • cargo test --no-default-features --features telemetry,tui,subsonic: 1645 passed, 0 failed, 13 ignored (includes url_encode_encodes_spaces_and_specials and create_playlist_encodes_the_name_and_returns_the_new_id)
  • cargo fmt --all -- --check: clean
  • cargo clippy --no-default-features --features telemetry,tui -- -D warnings: clean
  • cargo clippy --no-default-features --features telemetry,tui,subsonic -- -D warnings: clean
  • cargo test --no-default-features --features telemetry,tui: 1596 passed, 0 failed

Additional notes

I did not run the optional manual check against a Navidrome server.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Subsonic requests failing with server error 40 when usernames contain special characters or spaces. These characters are now encoded correctly in requests.

endpoint_url put the username into the query string raw, so a name with
+, &, #, %, = or a space reached the server altered and every request
failed with Subsonic error 40. Encode it with the existing url_encode.

Signed-off-by: Gaurav Jadhav <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T09:31:35.629211Z c8c7588 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: LargeModGames/spotatui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 78e3fed3-1d20-42cd-865d-04a78653ec16
📥 Commits

Reviewing files that changed from the base of the PR and between 5e48862 and c8c7588.

📒 Files selected for processing: 2
  • CHANGELOG.md
  • src/infra/subsonic/mod.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

Subsonic endpoint URLs now percent-encode usernames in the u query parameter. Tests cover usernames with query-sensitive characters and plain usernames. The changelog records the fix.

Changes: Subsonic username encoding

Layer / File(s) Summary
Endpoint URL username encoding
src/infra/subsonic/mod.rs, CHANGELOG.md
endpoint_url now applies url_encode to the username. Tests check special-character encoding and confirm that a plain username remains unchanged. The changelog records the fix.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to c8c75

Subsonic usernames containing query-sensitive characters are now encoded in REST request URLs. No merge-blocking issue is evident in the supplied change context.

Pre-merge checks: Passed 4
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title uses the allowed conventional-commit prefix fix, includes the optional subsonic scope, and concisely describes the main change in imperative form.
Linked Issues check Passed Issue #814 requires percent-encoding the username in SubsonicSource::endpoint_url and preserving url_encode. The diff applies url_encode(&self.username) to the u parameter. It leaves `url_enco…
Out of Scope Changes check Passed The changes stay within issue #814. The source change fixes username encoding, the added tests verify the required URL behavior, and the CHANGELOG.md entry documents the fix. No unrelated implementa…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
✨ Simplify code
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@LargeModGames
LargeModGames merged commit 218716f into LargeModGames:main Oct 15, 2026
32 checks passed
@LargeModGames

Copy link
Copy Markdown
Owner

@all-contributors please add @jadhavgaurav for code

@allcontributors

Copy link
Copy Markdown
Contributor

@LargeModGames

@jadhavgaurav already contributed before to code

@LargeModGames

Copy link
Copy Markdown
Owner

oops

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.

Subsonic: a username with +, &, # or a space can't log in

2 participants