mirror of
				https://github.com/louislam/uptime-kuma.git
				synced 2025-10-31 19:39:20 +08:00 
			
		
		
		
	Helpful error when query returns object or array
This commit is contained in:
		| @@ -407,6 +407,9 @@ async function evaluateJsonQuery(data, jsonPath, jsonPathOperator, expectedValue | ||||
|     } | ||||
|     try { | ||||
|         response = (jsonPath) ? await jsonata(jsonPath).evaluate(response) : response; | ||||
|         if (typeof response === "object" || Array.isArray(response) || response instanceof Date || typeof response === "function") { | ||||
|             throw new Error(`The post-JSON query evaluated response from the server is of type ${typeof response}, which cannot be directly compared to the expected value`); | ||||
|         } | ||||
|         let jsonQueryExpression; | ||||
|         switch (jsonPathOperator) { | ||||
|             case ">": | ||||
|   | ||||
| @@ -667,6 +667,10 @@ export async function evaluateJsonQuery(data: any, jsonPath: string, jsonPathOpe | ||||
|         // If a JSON path is provided, pre-evaluate the data using it. | ||||
|         response = (jsonPath) ? await jsonata(jsonPath).evaluate(response) : response; | ||||
|  | ||||
|         if (typeof response === "object" || Array.isArray(response) || response instanceof Date || typeof response === "function") { | ||||
|             throw new Error(`The post-JSON query evaluated response from the server is of type ${typeof response}, which cannot be directly compared to the expected value`); | ||||
|         } | ||||
|  | ||||
|         // Perform the comparison logic using the chosen operator | ||||
|         let jsonQueryExpression; | ||||
|         switch (jsonPathOperator) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user