Users reported seeing errors in Home Assistant Core logs:
Logger: homeassistant.components.hassio.handler
Client error on /ingress/validate_session request 401, message='Attempt to decode JSON with unexpected mimetype: text/plain; charset=utf-8', url='http://INTERNALIPADDRESS/ingress/validate_session'
Additionally, users reported:
- WebUI stuck in "initialization" stage
- Notification links redirecting to home dashboard instead of WebUI
When Home Assistant Supervisor probed the add-on's web server with requests to non-existent routes (like /ingress/validate_session), the web server returned HTML 404 responses. When the Supervisor tried to parse these as JSON, it caused the "unexpected mimetype" error.
Note: The /ingress/validate_session endpoint is part of the Home Assistant Supervisor API, not the add-on's API. The Supervisor validates ingress sessions itself.
Added intelligent 404 handling to the web server that distinguishes between API/JSON requests and browser requests.
File: ha_sentry/rootfs/app/web_server.py
-
Added
_handle_not_found()method (lines 634-656):- Checks if the request path starts with
/api/or/ingress/ - Checks if the request Accept header contains
json - Returns JSON 404 for API-like requests
- Returns HTML 404 for browser requests
- Checks if the request path starts with
-
Added catch-all route handler (line 156):
- Must be the last route added to prevent shadowing other routes
- Includes clear documentation about placement importance
File: tests/test_404_handling.py (new file)
Comprehensive test suite with 5 tests:
- API 404 returns JSON
- Ingress path 404 returns JSON
- JSON Accept header gets JSON 404
- Browser request returns HTML 404
- Valid routes still work correctly
All tests pass:
- ✅ test_404_handling.py (5 tests) - NEW
- ✅ test_notification_links.py (4 tests)
- ✅ test_ingress_url.py (3 tests)
- ✅ test_web_server.py (7 tests)
- ✅ test_web_server_503_handling.py
- ✅ Code review: No issues found
- ✅ Security scan: No vulnerabilities found
- ✅ Eliminates "unexpected mimetype" errors in HA Core logs
- ✅ Ensures proper JSON responses for Supervisor probes
- ✅ Maintains good user experience for browser requests
- ✅ No breaking changes to existing functionality
If users still see 401 errors for /ingress/validate_session:
- This is a Home Assistant Core/Supervisor issue, not an add-on issue
- Possible causes: expired sessions, cookie issues, reverse proxy configuration
- Solutions: Restart Home Assistant, check for HA updates, verify reverse proxy config
If WebUI still shows "Loading..." indefinitely:
- Check add-on logs for dependency graph build status
- Verify
enable_dependency_graph: truein configuration - Wait 60 seconds on first access (graph build takes time)
- Check browser console for JavaScript errors
If notification links still don't work:
- Use the "Sentry" sidebar panel (easiest access method)
- Try Settings → Add-ons → Home Assistant Sentry → Open Web UI
- Verify the ingress URL
/api/hassio_ingress/ha_sentryworks when entered manually - Update Home Assistant to the latest version
ha_sentry/rootfs/app/web_server.py: Added 404 handling (29 lines added)
tests/test_404_handling.py: Comprehensive test suite (156 lines)
aa38f73: Fix ingress 404 error - return JSON for API/ingress paths440fcda: Add clarifying comment for catch-all route placement
CodeQL security analysis completed with 0 alerts found. The changes:
- Do not introduce any security vulnerabilities
- Follow secure coding practices
- Properly escape HTML to prevent XSS
- Use appropriate status codes and content types
- Update the add-on to get this fix
- Restart the add-on after updating
- Access WebUI via sidebar panel (look for "Sentry" in HA sidebar)
- If issues persist, check add-on logs for specific error messages
- INGRESS_URL_INFO.md - Ingress URL format and troubleshooting
- WEBUI_ACCESS_GUIDE.md - WebUI access methods
- DOCS.md - Full add-on documentation