{"record":{"id":"a032426f97eab2be","repo":"langgenius/dify","slug":"server-4xx-other","errorCode":"server_4xx_other","errorMessage":"device/code: HTTP ${res.status}","messagePattern":"device/code: HTTP (.+?)","errorType":"http","errorClass":"HttpClientError","httpStatus":null,"severity":"error","filePath":"cli/src/api/oauth-device.ts","lineNumber":82,"sourceCode":"export class DeviceFlowApi {\n  private readonly http: HttpClient\n\n  constructor(http: HttpClient) {\n    this.http = http\n  }\n\n  async requestCode(req: CodeRequest): Promise<CodeResponse> {\n    if (req.device_label === '') {\n      throw new BaseError({\n        code: ErrorCode.UsageMissingArg,\n        message: 'device_label is required',\n      })\n    }\n    const body = { client_id: req.client_id ?? DEFAULT_CLIENT_ID, device_label: req.device_label }\n    const res = await this.http.fetch('oauth/device/code', { method: 'POST', json: body })\n    if (res.status === 404) throw versionSkew()\n    if (!res.ok) {\n      throw new HttpClientError({\n        code: ErrorCode.Server4xxOther,\n        message: `device/code: HTTP ${res.status}`,\n        httpStatus: res.status,\n      })\n    }\n    return (await res.json()) as CodeResponse\n  }\n\n  async pollOnce(req: PollRequest): Promise<PollResult> {\n    if (req.device_code === '') {\n      throw new BaseError({\n        code: ErrorCode.UsageMissingArg,\n        message: 'device_code is required',\n      })\n    }\n    const body = { client_id: req.client_id ?? DEFAULT_CLIENT_ID, device_code: req.device_code }\n    const res = await this.http.fetch('oauth/device/token', { method: 'POST', json: body })\n    if (res.status === 404) throw versionSkew()","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/cli/src/api/oauth-device.ts#L64-L100","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before — dataset retrieval_model references a provider with no credentials\nretrieval_model: { reranking_enable: true, reranking_model: { provider: 'cohere', model: 'rerank-multilingual-v3.0' } }\n// after — configure provider in Settings -> Model Provider, or disable reranking\nretrieval_model: { reranking_enable: false }","handlingStrategy":"validation","validationCode":"async function hasEmbeddingProvider(client): Promise<boolean> {\n  const r = await client.get('/console/api/workspaces/current/model-providers');\n  const providers = await r.json();\n  return providers.some(p => p.models?.some(m => m.model_type === 'text-embedding') && p.is_valid);\n}\nif (!(await hasEmbeddingProvider(client))) {\n  throw new Error('Configure an embedding provider in Settings -> Model Provider first');\n}","typeGuard":"interface ProviderConfig { model_type: string; is_valid: boolean; }\nfunction hasValidEmbedding(providers: ProviderConfig[]): boolean {\n  return providers.some(p => p.model_type === 'text-embedding' && p.is_valid);\n}","tryCatchPattern":"try {\n  await hitTesting(client, datasetId, query);\n} catch (e) {\n  if (e.response?.status === 400 && /Embedding Model/i.test(e.response.data?.message || '')) {\n    redirectTo('/settings/model-provider');  // guide user to configure\n    return;\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["model-provider","embedding","reranking","configuration","hit-testing","provider-error"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}