[Bug] /doctor prints provider and MCP URLs with embedded credentials, under "Secrets are not printed"
Description
/doctor prints the provider baseURL and the MCP server url exactly as configured (source/commands/doctor.tsx, lines 366 and 411). Some providers and MCP endpoints put a secret in the URL: a username and password, a token in the path, or an API key in the query string. The report is headed "Copy this report into bug reports. Secrets are not printed.", so users will paste it into public issues.
Environment
- OS: Windows 11 (10.0.26300)
- Node version: 22.22.3
- Nanocoder version: 1.31.0 (main at 5c2e693)
- Provider / Model: not relevant
Steps to Reproduce
- In
agents.config.json, add a provider with"baseUrl": "https://user:[email protected]/v1?key=QUERYKEY-LEAKCHECK". - Add an HTTP MCP server with
"url": "https://mcp.example.com/api/mcp/s/PATHTOKEN-LEAKCHECK/mcp?api_key=APIKEY-LEAKCHECK". - Run
/doctorin the interactive app.
Expected Behavior
Passwords, tokens and API keys in URLs are not shown. For example https://proxy.example.com/v1 and https://mcp.example.com/api/mcp/s/<redacted>/mcp.
Actual Behavior
The whole report prints all four secrets. I rendered the Doctor component with the real config loader and a real MCP client (I did not run the TUI):
│ Copy this report into bug reports. Secrets are not printed. │
│ • ProxyProvider: 1 model • hosted • https://user:sk-test-LEAKCHECK123@ │
│ proxy.example.com/v1?key=QUERYKEY-LEAKCHECK │
│ • zapier-like: http • 0 tools • https://mcp.example.com/api/mcp/s/PATH │
│ TOKEN-LEAKCHECK/mcp?api_key=APIKEY-LEAKCHECK │
Suggested Fix
- In
source/commands/doctor.tsx, runprovider.baseURL(line 366) andserver.url(line 411) through one small function before printing it. It should remove the username and password, drop the query string, and mask long path segments. - A good place for the helper is
collectProviders/collectMcp, so the redacted value is what ends up in the report data. I could not find an existing helper for URLs. - Add a test in
source/commands/doctor.spec.tsxlike the one above: render a report with secret-looking URLs and check that none of the secrets appear (remove│and line breaks first, because long URLs wrap).
Additional Context
- Original command request: #609.
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder
Hey @insuffer, thanks for the PR! I'll review it for now. From next time, please comment on the issue to ask for assignment and wait until you're assigned before opening a PR. Feel free to grab another unassigned issue too.
Hi @anithanarayanswamy , I’m assigning this one to you. I’ll review your PR this time. Going forward, please comment on the issue first and wait until you’re assigned before you start working on it. That way we avoid duplicate work and keep things fair for everyone. Thanks for contributing! 🙌
Hi @addyCooks, I have prepared the fix for #1661 in PR #1881 and addressed the path masking review feedback. Could you please assign this issue to me? Thanks!