From 232da6133cdd984e59fca5c2109d7d69ffd511a0 Mon Sep 17 00:00:00 2001 From: delchev Date: Thu, 27 Aug 2026 19:35:34 +0300 Subject: [PATCH] Monitoring Logs: read a log file as text/plain instead of failing content negotiation The shell api helper hardwired Accept: application/json while GET /services/ide/logs/{file} produces text/plain, so every file read answered 406 before the handler ran and the Logs page showed 'The file could not be read.' for every file. api.js gains a per-call Accept override ({ accept: ... }, JSON stays the default) and the monitoring ops.logFile requests text/plain. Fixes #6968 Co-Authored-By: Claude Fable 5 --- .../dirigible/application-core/shell/js/services/api.js | 5 ++++- .../META-INF/dirigible/monitoring/js/services/ops.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/components/resources/application-core/src/main/resources/META-INF/dirigible/application-core/shell/js/services/api.js b/components/resources/application-core/src/main/resources/META-INF/dirigible/application-core/shell/js/services/api.js index 5fa0dda581a..011b9c8a740 100644 --- a/components/resources/application-core/src/main/resources/META-INF/dirigible/application-core/shell/js/services/api.js +++ b/components/resources/application-core/src/main/resources/META-INF/dirigible/application-core/shell/js/services/api.js @@ -96,7 +96,10 @@ App.services.api = { // X-Requested-With marks the call as programmatic for browsers without Sec-Fetch-Mode: the // server then answers an expired session with a PLAIN 401 (no Basic challenge), so the // browser's native login dialog never pops over a background poll. - const headers = { 'Accept': 'application/json', 'X-Requested-With': 'XMLHttpRequest' }; + // A caller may pin the Accept header for THIS call ({ accept: 'text/plain' }) - e.g. the + // monitoring Logs page, whose file endpoint produces text/plain and answers 406 to a JSON-only + // Accept before the handler even runs. JSON stays the default. + const headers = { 'Accept': opts.accept || 'application/json', 'X-Requested-With': 'XMLHttpRequest' }; if (!isForm) headers['Content-Type'] = 'application/json'; // A caller may pin the request language for THIS call ({ language: 'bg' }) — e.g. Print, where the // chosen print language must drive the multilingual data overlay, not the UI locale. Absent the diff --git a/components/resources/resources-monitoring/src/main/resources/META-INF/dirigible/monitoring/js/services/ops.js b/components/resources/resources-monitoring/src/main/resources/META-INF/dirigible/monitoring/js/services/ops.js index d199f828df1..881dc7f6bce 100644 --- a/components/resources/resources-monitoring/src/main/resources/META-INF/dirigible/monitoring/js/services/ops.js +++ b/components/resources/resources-monitoring/src/main/resources/META-INF/dirigible/monitoring/js/services/ops.js @@ -105,7 +105,7 @@ window.MonitoringOps = (() => { logFiles: () => get('/services/ide/logs/'), /** One log file, whole. It is never polled - the page tails what it loaded. */ - logFile: (file) => get('/services/ide/logs/' + encodeURIComponent(file)), + logFile: (file) => App.services.api.get('/services/ide/logs/' + encodeURIComponent(file), { ...ABSOLUTE, accept: 'text/plain' }), /** * Run a read that must not take the page down with it. A monitoring screen exists to show what is