fix(admin): scrub the re-serialised base URL from provider errors

sanitizeProviderErr now also replaces the URL as net/url writes it.
A provider baseUrl with userinfo, a query or a fragment logs one
construction warning. The config still loads.
This commit is contained in:
2026-11-29 00:23:11 +00:00
parent d01e287ea2
commit 7d43366324
3 changed files with 94 additions and 6 deletions
+9 -5
View File
@@ -299,20 +299,24 @@ const unparseableBaseURLPlaceholder = "[unparseable url]"
//
// Still best-effort for URLs OTHER than rawBaseURL: an error naming a
// redirect target is not caught. Rejecting a credential-bearing baseUrl
// at construction (providers.go) is the only complete fix; this is the
// containment that changes no behavior.
// at construction (providers.go) would be the complete fix; instead the
// constructor only warns, so a config that loads today keeps loading.
func sanitizeProviderErr(lastErr, rawBaseURL string) string {
if lastErr == "" || rawBaseURL == "" {
return lastErr
}
out := replaceURLForm(lastErr, rawBaseURL)
u, parseErr := url.Parse(rawBaseURL)
if parseErr != nil || u.User == nil {
if parseErr != nil {
return out
}
// net/http reports url.URL.String(), which lower-cases the scheme and
// re-escapes userinfo, so it can differ from the configured text.
out = replaceURLForm(out, u.String())
if u.User == nil {
return out
}
if _, hasPassword := u.User.Password(); !hasPassword {
// No password set means net/http passed the URL through
// unmasked, so the verbatim pass above already matched it.
return out
}
// net/http's exact stripPassword output, mirrored call for call.