fix(proxy): return Result from get_auth_headers to avoid panic on bad credentials

User-pasted API keys can contain control chars or CR/LF that make
HeaderValue::from_str return Err; the previous unwrap inside every
adapter turned such input into a process-wide panic instead of a request
error. The trait now returns Result<_, ProxyError>; Claude/Codex/Gemini
impls propagate ProxyError::AuthError so the client sees a 401 with the
underlying parse error instead of a crash. Adds a regression test that
pastes a CRLF-containing key and asserts AuthError.
This commit is contained in:
Jason
2026-05-13 23:12:00 +08:00
parent 58648a9c53
commit c9a6afc0b7
5 changed files with 65 additions and 43 deletions
+1 -1
View File
@@ -1151,7 +1151,7 @@ impl RequestForwarder {
}
}
adapter.get_auth_headers(&auth)
adapter.get_auth_headers(&auth)?
} else {
Vec::new()
};