ToolJet/ToolJet · error · QueryError
Query could not be completed
Error message
Query could not be completed
What it means
The Elasticsearch run() method wraps its entire operation switch in one try/catch. Any failure — SDK transport error, missing index, malformed query DSL, auth rejection, the 'Unsupported operation' default throw — is normalized into a QueryError titled 'Query could not be completed' with the original err.message as description. The original error object is not preserved in data (an empty object is passed). A console.log(err) also leaks the full error to server logs.
Source
Thrown at plugins/packages/elasticsearch/lib/index.ts:72
break;
case 'scroll':
result = await scrollSearch(client, queryOptions.scroll_id, queryOptions.scroll);
break;
case 'clear_scroll':
result = await clearScroll(client, queryOptions.scroll_id);
break;
case 'cat_indices':
result = await getCatIndices(client);
break;
case 'cluster_health':
result = await getClusterHealth(client);
break;
default:
throw new Error(`Unsupported operation: ${operation}`);
}
} catch (err) {
console.log(err);
throw new QueryError('Query could not be completed', err.message, {});
}
return {
status: 'ok',
data: result,
};
}
async testConnection(sourceOptions: SourceOptions): Promise<ConnectionTestResult> {
try {
const client = await this.getConnection(sourceOptions);
await client.info();
return {
status: 'ok',
message: 'Connection successful',
};
} catch (err: any) {
const errorMessage = err || 'Unknown error';View on GitHub (pinned to 20602a8e10)
Solutions
- Read the QueryError.description — it carries the underlying transport/DSL message which identifies the real cause.
- Verify host, port, protocol (determineProtocol logic), and credentials in the datasource; re-run test connection.
- If SSL is on, provide the correct CA / client cert / key in the datasource SSL fields.
- For query DSL errors, validate the body JSON against the cluster's mapping before sending.
- For scroll errors, re-issue the initial search to obtain a fresh scroll_id.
Example fix
// before — index name typo causes NotFound
queryOptions = { operation: 'search', index: 'order', query: {...} };
// after
queryOptions = { operation: 'search', index: 'orders', query: {...} }; Defensive patterns
Strategy: try-catch
Validate before calling
function validateEsQuery(qo) {
if (qo.operation === 'search' && !qo.index) throw new Error('index required for search');
if (['get','update','delete','exists'].includes(qo.operation) && !qo.id) throw new Error('id required for ' + qo.operation);
if (qo.operation === 'bulk' && !Array.isArray(qo.operations)) throw new Error('operations array required for bulk');
} Try / catch
try { await plugin.run(sourceOptions, queryOptions); }
catch (e) { if (e instanceof QueryError && e.message === 'Query could not be completed') { console.error('ES detail:', e.description); /* e.description is the transport/DSL message */ } else throw e; } Prevention
- Validate the query DSL JSON against the cluster mapping before sending.
- Confirm host/port/protocol/credentials with testConnection first.
- Provide the correct SSL CA when TLS is enabled.
When it happens
Trigger: Network/TLS error reaching the OpenSearch/Elasticsearch node. Auth failure (wrong credentials, encoded username/password mismatch). Index not found on search/get. Malformed query body (JSON parse or DSL validation). Bulk operation with a malformed actions array. Scroll using an expired or unknown scroll_id. cat_indices/cluster_health failing because the user lacks cluster permissions.
Common situations: Host/port/protocol misconfiguration in the datasource (http vs https, wrong port). Self-signed cert without the CA configured. Username/password with special characters not URL-encoded (getConnection uses encodeURIComponent, but a stale config may pre-encode). Querying a deleted index. Scroll context expired (>1m keep-alive). Cluster权限 insufficient for cat APIs.
Related errors
- Unsupported operation: ${operation}
- Unknown error
- API call error
- Connection failed
- Query could not be completed
AI-assisted analysis of ToolJet/ToolJet@20602a8e10 (2026-08-13).
Data as JSON: /api/errors/4d7925d18136e58f.
Report an issue: GitHub.