Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

Fix: Make exists in small case recognise as valid non value op (#9989)

Aditya Singh2719c9b6a7d7
diff --git a/frontend/src/utils/__tests__/queryContextUtils.test.ts b/frontend/src/utils/__tests__/queryContextUtils.test.ts
index d0a69d94e3..363ceeb704 100644
--- a/frontend/src/utils/__tests__/queryContextUtils.test.ts
+++ b/frontend/src/utils/__tests__/queryContextUtils.test.ts
@@ -380,6 +380,23 @@ describe('extractQueryPairs', () => {
consoleSpy.mockRestore();
});
+
+ test('should treat lowercase exists as non-value operator', () => {
+ const input = 'body exists service.name contains "test"';
+ const result = extractQueryPairs(input);
+
+ expect(result).toHaveLength(2);
+ expect(result[0].key).toBe('body');
+ expect(result[0].operator).toBe('exists');
+ expect(result[0].value).toBeUndefined();
+ expect(result[0].valuesPosition).toEqual([]);
+ expect(result[0].isComplete).toBe(false);
+ expect(result[1].key).toBe('service.name');
+ expect(result[1].operator).toBe('contains');
+ expect(result[1].value).toBe('"test"');
+ expect(result[1].valuesPosition).toEqual([]);
+ expect(result[1].isComplete).toBe(true);
+ });
});
describe('createContext', () => {
diff --git a/frontend/src/utils/queryContextUtils.ts b/frontend/src/utils/queryContextUtils.ts
index d337f75eac..45ee5cb924 100644
--- a/frontend/src/utils/queryContextUtils.ts
+++ b/frontend/src/utils/queryContextUtils.ts
@@ -10,12 +10,12 @@ import {
isFunctionToken,
isKeyToken,
isMultiValueOperator,
+ isNonValueOperator,
isNonValueOperatorToken,
isOperatorToken,
isQueryPairComplete,
isValueToken,
} from './tokenUtils';
-import { NON_VALUE_OPERATORS } from 'constants/antlrQueryConstants';
// Function to create a context object
export function createContext(
@@ -1319,7 +1319,7 @@ export function extractQueryPairs(query: string): IQueryPair[] {
currentPair &&
currentPair.key &&
currentPair.operator &&
- !NON_VALUE_OPERATORS.includes(currentPair.operator) &&
+ !isNonValueOperator(currentPair.operator) &&
!currentPair.value
) {
currentPair.value = token.text;
diff --git a/frontend/src/utils/tokenUtils.ts b/frontend/src/utils/tokenUtils.ts
index 98d164139d..76a560910e 100644
--- a/frontend/src/utils/tokenUtils.ts
+++ b/frontend/src/utils/tokenUtils.ts
@@ -87,16 +87,6 @@ export function isWrappedUnderQuotes(token: string): boolean {
);
}
-export function isQueryPairComplete(queryPair: Partial<IQueryPair>): boolean {
- if (!queryPair) return false;
- // A complete query pair must have a key, an operator, and a value (or EXISTS operator)
- if (queryPair.operator && NON_VALUE_OPERATORS.includes(queryPair.operator)) {
- return !!queryPair.key && !!queryPair.operator;
- }
- // For other operators, we need a value as well
- return Boolean(queryPair.key && queryPair.operator && queryPair.value);
-}
-
export function isFunctionOperator(operator: string): boolean {
const functionOperators = Object.values(QUERY_BUILDER_FUNCTIONS);
@@ -134,3 +124,13 @@ export function isNonValueOperator(operator: string): boolean {
}
return false;
}
+
+export function isQueryPairComplete(queryPair: Partial<IQueryPair>): boolean {
+ if (!queryPair) return false;
+ // A complete query pair must have a key, an operator, and a value (or EXISTS operator)
+ if (queryPair.operator && isNonValueOperator(queryPair.operator)) {
+ return !!queryPair.key && !!queryPair.operator;
+ }
+ // For other operators, we need a value as well
+ return Boolean(queryPair.key && queryPair.operator && queryPair.value);
+}