fix: handle undefined bucket filters in AQL query rewriter (#12)
The network patch that intercepts /api/0/query/ requests only handled
'unknown' hostnames in bucket IDs. When the WebUI activity store has
uninitialized bucket IDs (e.g. browser watcher not installed on a host),
find_bucket("undefined") or query_bucket("undefined") calls reach the
server and fail with BucketQueryError.
Extend rewriteUnknownCategoryBuilderQueryBody to:
- Replace query_bucket(find_bucket("undefined")) and flood() wrappers
with empty arrays ([]) so the query continues without missing data.
- Rewrite aw-watcher-{window,afk}_undefined to the preferred host,
matching the existing 'unknown' hostname logic.
Applied to both aw-server/ and install-kit copies of aw-ru-patch.js.
Fixes: BucketЗапросError on Trends page for host SHARKON2025
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
f7cf5556a0
commit
36e4255ad9
@@ -1541,14 +1541,28 @@
|
||||
|
||||
function rewriteUnknownCategoryBuilderQueryBody(body) {
|
||||
if (typeof body !== "string") return body;
|
||||
if (body.indexOf("aw-watcher-window_unknown") === -1 && body.indexOf("aw-watcher-afk_unknown") === -1) {
|
||||
return body;
|
||||
if (body.indexOf("undefined") !== -1) {
|
||||
body = body
|
||||
.replace(/flood\(query_bucket\(find_bucket\(\\"undefined\\"\)\)\)/g, '[]')
|
||||
.replace(/query_bucket\(find_bucket\(\\"undefined\\"\)\)/g, '[]')
|
||||
.replace(/flood\(query_bucket\(\\"undefined\\"\)\)/g, '[]')
|
||||
.replace(/query_bucket\(\\"undefined\\"\)/g, '[]');
|
||||
const ph = getPreferredWindowHostFromBuckets();
|
||||
if (ph) {
|
||||
body = body
|
||||
.replace(/aw-watcher-window_undefined/g, "aw-watcher-window_" + ph)
|
||||
.replace(/aw-watcher-afk_undefined/g, "aw-watcher-afk_" + ph);
|
||||
}
|
||||
}
|
||||
const preferredHost = getPreferredWindowHostFromBuckets();
|
||||
if (!preferredHost) return body;
|
||||
return body
|
||||
.replace(/aw-watcher-window_unknown/g, "aw-watcher-window_" + preferredHost)
|
||||
.replace(/aw-watcher-afk_unknown/g, "aw-watcher-afk_" + preferredHost);
|
||||
if (body.indexOf("aw-watcher-window_unknown") !== -1 || body.indexOf("aw-watcher-afk_unknown") !== -1) {
|
||||
const preferredHost = getPreferredWindowHostFromBuckets();
|
||||
if (preferredHost) {
|
||||
body = body
|
||||
.replace(/aw-watcher-window_unknown/g, "aw-watcher-window_" + preferredHost)
|
||||
.replace(/aw-watcher-afk_unknown/g, "aw-watcher-afk_" + preferredHost);
|
||||
}
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
function installCategoryBuilderNetworkPatch() {
|
||||
|
||||
@@ -1500,14 +1500,28 @@
|
||||
|
||||
function rewriteUnknownCategoryBuilderQueryBody(body) {
|
||||
if (typeof body !== "string") return body;
|
||||
if (body.indexOf("aw-watcher-window_unknown") === -1 && body.indexOf("aw-watcher-afk_unknown") === -1) {
|
||||
return body;
|
||||
if (body.indexOf("undefined") !== -1) {
|
||||
body = body
|
||||
.replace(/flood\(query_bucket\(find_bucket\(\\"undefined\\"\)\)\)/g, '[]')
|
||||
.replace(/query_bucket\(find_bucket\(\\"undefined\\"\)\)/g, '[]')
|
||||
.replace(/flood\(query_bucket\(\\"undefined\\"\)\)/g, '[]')
|
||||
.replace(/query_bucket\(\\"undefined\\"\)/g, '[]');
|
||||
const ph = getPreferredWindowHostFromBuckets();
|
||||
if (ph) {
|
||||
body = body
|
||||
.replace(/aw-watcher-window_undefined/g, "aw-watcher-window_" + ph)
|
||||
.replace(/aw-watcher-afk_undefined/g, "aw-watcher-afk_" + ph);
|
||||
}
|
||||
}
|
||||
const preferredHost = getPreferredWindowHostFromBuckets();
|
||||
if (!preferredHost) return body;
|
||||
return body
|
||||
.replace(/aw-watcher-window_unknown/g, "aw-watcher-window_" + preferredHost)
|
||||
.replace(/aw-watcher-afk_unknown/g, "aw-watcher-afk_" + preferredHost);
|
||||
if (body.indexOf("aw-watcher-window_unknown") !== -1 || body.indexOf("aw-watcher-afk_unknown") !== -1) {
|
||||
const preferredHost = getPreferredWindowHostFromBuckets();
|
||||
if (preferredHost) {
|
||||
body = body
|
||||
.replace(/aw-watcher-window_unknown/g, "aw-watcher-window_" + preferredHost)
|
||||
.replace(/aw-watcher-afk_unknown/g, "aw-watcher-afk_" + preferredHost);
|
||||
}
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
function installCategoryBuilderNetworkPatch() {
|
||||
|
||||
Reference in New Issue
Block a user