ToolJet/ToolJet · error · QueryError
Connection test failed
Error message
Connection test failed
What it means
testConnection()'s outer catch swallows every error — including the informative 'API responded with status N' from error 153 — and re-throws a generic QueryError('Connection test failed', 'Could not establish connection to Hugging Face API. Please check your credentials.', {}). This destroys the HTTP status and original message, so callers cannot distinguish 401 (bad token) from 429 (rate limit) from network failure. data is always {}, giving the caller no structured context.
Source
Thrown at marketplace/plugins/hugging_face/lib/index.ts:66
try {
const response = await fetch('https://huggingface.co/api/whoami-v2', {
method: 'GET',
headers: {
Authorization: `Bearer ${personal_access_token}`,
'Content-Type': 'application/json',
},
});
if (!response.ok) {
throw new Error(`API responded with status ${response.status}`);
}
return {
status: 'ok',
};
} catch (error) {
throw new QueryError(
'Connection test failed',
'Could not establish connection to Hugging Face API. Please check your credentials.',
{}
);
}
}
}
View on GitHub (pinned to 20602a8e10)
Solutions
- Patch the catch to preserve error.message and include structured data (HTTP status, error type) so callers can diagnose.
- Distinguish error shapes before wrapping: HTTPError/non-OK (preserve status), TypeError/network (report connectivity), other (report unknown).
- In the caller, treat 'Connection test failed' as a generic flag and re-run with verbose logging on the plugin side to recover the real cause.
- Add a retry with backoff for transient (429/5xx/network) failures before declaring the connection failed.
Example fix
// before — destroys the inner cause
} catch (error) {
throw new QueryError(
'Connection test failed',
'Could not establish connection to Hugging Face API. Please check your credentials.',
{}
);
}
// after — preserve the original message and status
} catch (error) {
throw new QueryError(
'Connection test failed',
error?.message ?? 'Could not establish connection to Hugging Face API. Please check your credentials.',
{ status: error?.status, name: error?.name }
);
} Defensive patterns
Strategy: try-catch
Validate before calling
// Nothing the caller can validate that the plugin cannot; mitigate by patching the
// catch to preserve the inner error.
function patchTestConnection(plugin) {
const orig = plugin.testConnection.bind(plugin);
plugin.testConnection = async (so) => {
try { return await orig(so); }
catch (e) {
// re-tag with whatever inner message we can recover
throw new Error(`HF test failed: ${e.description ?? e.message}`);
}
};
} Type guard
function isHfConnectionTestFailure(e): boolean {
return e?.name === 'QueryError' && e?.message === 'Connection test failed';
} Try / catch
try {
await hf.testConnection(sourceOptions);
} catch (e) {
if (e.name === 'QueryError' && e.message === 'Connection test failed') {
// Description is generic; perform a direct whoami-v2 call to recover the status:
const r = await fetch('https://huggingface.co/api/whoami-v2', {
headers: { Authorization: `Bearer ${sourceOptions.personal_access_token}` }
});
return { ok: r.ok, status: r.status };
}
throw e;
} Prevention
- Patch the plugin's catch to preserve error.message and HTTP status.
- Run a direct whoami-v2 call from your own code if you need the real status (the plugin discards it).
- Add retry/backoff for transient (429/5xx) failures before declaring failure.
When it happens
Trigger: Any throw inside testConnection's try: response.ok false (error 153), fetch network/DNS failure, response.json parse failure, or an unexpected exception. The catch is unconditional.
Common situations: Operator clicks 'Test Connection' and sees only a generic credentials hint despite the real cause being rate-limiting, network outage, or a temporary HF API incident; support tickets escalate because the message points to credentials when the issue is elsewhere.
Related errors
- Text generation operation failed
- Summarisation operation failed
- Could not connect to Googles Calendar
- Query could not be completed
- API responded with status ${response.status}
AI-assisted analysis of ToolJet/ToolJet@20602a8e10 (2026-08-13).
Data as JSON: /api/errors/6e00d5051770f3bb.
Report an issue: GitHub.