Skip to content

Add URL encoding for Redis credentials and safer error handling in sessions#39

Closed
Copilot wants to merge 1 commit intomodernize-rust-syntaxfrom
copilot/sub-pr-38
Closed

Add URL encoding for Redis credentials and safer error handling in sessions#39
Copilot wants to merge 1 commit intomodernize-rust-syntaxfrom
copilot/sub-pr-38

Conversation

Copy link
Copy Markdown

Copilot AI commented Jan 18, 2026

Addresses two robustness issues identified in code review:

1. URL-encode Redis credentials

Credentials containing URL-unsafe characters (@, :, /, ?, #) would break connection string parsing. Added percent-encoding using percent-encoding crate (already in dep tree):

// Before - fails with special chars
format!("{}:{}@", username, password)

// After
let encoded_user = utf8_percent_encode(u, NON_ALPHANUMERIC);
let encoded_pass = utf8_percent_encode(p, NON_ALPHANUMERIC);
format!("{}:{}@", encoded_user, encoded_pass)

2. Replace bare unwrap() with expect() in sessions.rs

Changed panic-on-None to include context about the invariant:

// Before
Ok(session_token.unwrap())

// After  
Ok(session_token.expect("session_token must be Some after creation or retrieval"))

While code flow guarantees Some, explicit message aids debugging if logic error introduced.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Modernize Rust syntax patterns Add URL encoding for Redis credentials and safer error handling in sessions Jan 18, 2026
Copilot AI requested a review from cmyui January 18, 2026 22:53
@cmyui cmyui closed this Jan 18, 2026
@cmyui cmyui deleted the copilot/sub-pr-38 branch January 18, 2026 22:53
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.

2 participants