langgenius/dify · error · HttpClientError
server_4xx_other
server_4xx_other
Error message
device/code: HTTP ${res.status} What it means
Raised when HitTestingService.retrieve raises LLMBadRequestError, which perform_hit_testing translates into ProviderNotInitializeError with this message. It indicates the configured model provider cannot fulfil the embedding or reranking call — most often because no embedding/reranking model is configured for the tenant, or the configured provider's credentials are missing/invalid. This is a configuration error, not a dataset or query error.
Source
Thrown at cli/src/api/oauth-device.ts:82
export class DeviceFlowApi {
private readonly http: HttpClient
constructor(http: HttpClient) {
this.http = http
}
async requestCode(req: CodeRequest): Promise<CodeResponse> {
if (req.device_label === '') {
throw new BaseError({
code: ErrorCode.UsageMissingArg,
message: 'device_label is required',
})
}
const body = { client_id: req.client_id ?? DEFAULT_CLIENT_ID, device_label: req.device_label }
const res = await this.http.fetch('oauth/device/code', { method: 'POST', json: body })
if (res.status === 404) throw versionSkew()
if (!res.ok) {
throw new HttpClientError({
code: ErrorCode.Server4xxOther,
message: `device/code: HTTP ${res.status}`,
httpStatus: res.status,
})
}
return (await res.json()) as CodeResponse
}
async pollOnce(req: PollRequest): Promise<PollResult> {
if (req.device_code === '') {
throw new BaseError({
code: ErrorCode.UsageMissingArg,
message: 'device_code is required',
})
}
const body = { client_id: req.client_id ?? DEFAULT_CLIENT_ID, device_code: req.device_code }
const res = await this.http.fetch('oauth/device/token', { method: 'POST', json: body })
if (res.status === 404) throw versionSkew()View on GitHub (pinned to ef8544b173)
Solutions
- Open Settings -> Model Provider in the console and configure a valid embedding (and, if used, reranking) provider.
- Verify the dataset's configured retrieval_model references providers that are currently enabled for the tenant.
- After configuring, re-run the hit-testing request; no code change is required.
Example fix
// before — dataset retrieval_model references a provider with no credentials
retrieval_model: { reranking_enable: true, reranking_model: { provider: 'cohere', model: 'rerank-multilingual-v3.0' } }
// after — configure provider in Settings -> Model Provider, or disable reranking
retrieval_model: { reranking_enable: false } Defensive patterns
Strategy: validation
Validate before calling
async function hasEmbeddingProvider(client): Promise<boolean> {
const r = await client.get('/console/api/workspaces/current/model-providers');
const providers = await r.json();
return providers.some(p => p.models?.some(m => m.model_type === 'text-embedding') && p.is_valid);
}
if (!(await hasEmbeddingProvider(client))) {
throw new Error('Configure an embedding provider in Settings -> Model Provider first');
} Type guard
interface ProviderConfig { model_type: string; is_valid: boolean; }
function hasValidEmbedding(providers: ProviderConfig[]): boolean {
return providers.some(p => p.model_type === 'text-embedding' && p.is_valid);
} Try / catch
try {
await hitTesting(client, datasetId, query);
} catch (e) {
if (e.response?.status === 400 && /Embedding Model/i.test(e.response.data?.message || '')) {
redirectTo('/settings/model-provider'); // guide user to configure
return;
}
throw e;
} Prevention
- Configure and validate an embedding provider before indexing any dataset.
- If using reranking, ensure a valid rerank provider is configured before enabling it in retrieval_model.
- Periodically verify provider credentials have not expired or been revoked.
When it happens
Trigger: POST /datasets/{dataset_id}/hit-testing on a dataset whose indexing_mode requires an embedding model, but the tenant has no default embedding provider configured; or a reranking model is selected in retrieval_model but the provider credentials were removed.
Common situations: Freshly deployed instance where the model provider was never set up; tenant admin removed a provider credential that the dataset relies on; switched dataset retrieval mode to one requiring reranking without configuring a rerank model.
Related errors
- provider_not_initialize
- provider_not_initialize
- provider_not_support_speech_to_text
- model_currently_not_support
- provider_not_support_speech_to_text
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/a032426f97eab2be.
Report an issue: GitHub.