Improve error messages for channels unauthorized or forbidden
Checklist
- I added a descriptive title
- I searched open requests and couldn't find a duplicate
What is the idea?
Improve error messages for HTTP 401 and 403 errors when accessing private channels. Current messages are generic and don't tell users what to do.
Why is this needed?
Users get stuck on authentication errors because:
- 403 errors are treated like 404s, making users think the channel doesn't exist
- No actionable guidance (e.g., run
anaconda login, request access) - Same generic message whether they need to log in, fix credentials, or request permission
What should happen?
These are examples for anaconda-auth which would be Anaconda specific, we may want to make this a pluggable interface for conda-auth and other auth providers (see additional context).
For 403 (authorization failed):
- No token: suggest
anaconda login - Token present: explain it lacks permission, suggest requesting access
- Include
anaconda show USER/CHANNELto check permissions
For 401 (authentication failed):
- Explain token is invalid
- Suggest
anaconda logoutthenanaconda login
Example improved message:
The remote server has indicated you do not have permission to access this channel.
This is a private channel that requires authentication. You will need to:
(a) log in with `anaconda login` to authenticate, or
(b) request access from the channel owner.
Check your permissions with `anaconda show USER/CHANNEL`.
Additional Context
Files to modify:
conda/gateways/repodata/__init__.pyconda/gateways/connection/download.py- Tests in
tests/gateways/test_repodata_gateway.pyandtests/test_fetch.py
Open question: Should we add plugin hooks for auth error messages?
Different auth providers might want to customize error messages for their specific flows. Could add a simple hook:
custom_message = context.plugin_manager.get_auth_error_message(status_code, url, channel) if custom_message: return custom_message