Skip to content

Commit 0598048

Browse files
committed
text: add workaround for AJDA-1935 to improve Streamlit health check handling
1 parent 0b81245 commit 0598048

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

internal/pkg/service/appsproxy/proxy/pagewriter/pagewriter.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ func (pw *Writer) MountAssets(mux *http.ServeMux) {
6262
}
6363

6464
func (pw *Writer) writePage(w http.ResponseWriter, req *http.Request, page string, status int, data any) {
65-
// Streamlit health checks expect plain text responses, not HTML
65+
// WORKAROUND for AJDA-1935: Return plain text for Streamlit health checks.
66+
// Streamlit displays error responses in a modal that doesn't properly render HTML,
67+
// resulting in broken/escaped HTML being shown to users. This returns plain text
68+
// for known Streamlit internal endpoints to provide a better user experience.
69+
// See IsStreamlitHealthCheck() for full documentation and limitations.
6670
if IsStreamlitHealthCheck(req.URL.Path) {
6771
plainText := renderPlainText(page, status)
6872
w.Header().Set("Content-Type", "text/plain; charset=utf-8")

internal/pkg/service/appsproxy/proxy/pagewriter/pathutil.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ package pagewriter
22

33
import "strings"
44

5+
// IsStreamlitHealthCheck detects Streamlit health check endpoints.
6+
//
7+
// WORKAROUND: This is a temporary solution for AJDA-1935 to prevent broken HTML
8+
// from being displayed in Streamlit's error modal when the app is starting or unavailable.
9+
// Streamlit makes health check requests to these endpoints and renders the response
10+
// in an error dialog, which doesn't properly handle HTML responses.
11+
//
12+
// Limitations:
13+
// - This approach is Streamlit-specific and does not scale to other frameworks
14+
// - Only covers /_stcore/health and /_stcore/host-config endpoints
15+
// - Other Streamlit internal endpoints (e.g., /_stcore/stream) are not covered
16+
//
17+
// Long-term solution: Modify Streamlit to properly handle HTML error responses
18+
// or provide a query parameter for clients to request plain text format.
519
func IsStreamlitHealthCheck(path string) bool {
620
return strings.HasSuffix(path, "/_stcore/health") || strings.HasSuffix(path, "/_stcore/host-config")
721
}

0 commit comments

Comments
 (0)