{"record":{"id":"1012832aefbedc1d","repo":"Mintplex-Labs/anything-llm","slug":"docker-model-runner-chat-this-model-is-not-val","errorCode":null,"errorMessage":"Docker Model Runner chat: ${this.model} is not valid or defined model for chat completion!","messagePattern":"Docker Model Runner chat: (.+?) is not valid or defined model for chat completion!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/dockerModelRunner/index.js","lineNumber":150,"sourceCode":"    attachments = [],\n  }) {\n    const prompt = {\n      role: \"system\",\n      content: `${systemPrompt}${this.#appendContext(contextTexts)}`,\n    };\n    return [\n      prompt,\n      ...formatChatHistory(chatHistory, this.#generateContent),\n      {\n        role: \"user\",\n        content: this.#generateContent({ userPrompt, attachments }),\n      },\n    ];\n  }\n\n  async getChatCompletion(messages = null, { temperature = 0.7 }) {\n    if (!this.model)\n      throw new Error(\n        `Docker Model Runner chat: ${this.model} is not valid or defined model for chat completion!`\n      );\n\n    const result = await LLMPerformanceMonitor.measureAsyncFunction(\n      this.dmr.chat.completions.create({\n        model: this.model,\n        messages,\n        temperature,\n      })\n    );\n\n    if (\n      !result.output.hasOwnProperty(\"choices\") ||\n      result.output.choices.length === 0\n    )\n      return null;\n\n    return {","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/dockerModelRunner/index.js#L132-L168","documentation":"Thrown by getChatCompletion when this.model is falsy. Unlike other providers that call isValidChatCompletionModel against a live API or cache, Docker Model Runner simply checks truthiness — the constructor already enforces a model, so this guard fires only if this.model was cleared or never set after construction bypass. The check does not validate that the model is actually loaded in the runner.","triggerScenarios":"this.model is null/undefined/empty at call time; the constructor was bypassed or the model property was overwritten to a falsy value after instantiation; a subclass or test mock set this.model to undefined.","commonSituations":"Programmatic usage that nulls this.model after construction; test mocks that skip the constructor; edge case where modelPreference and env var are both empty but construction somehow proceeded.","solutions":["Ensure DOCKER_MODEL_RUNNER_LLM_MODEL_PREF or the modelPreference argument was set at construction time (the constructor already guards this).","Verify this.model was not overwritten to a falsy value between construction and the getChatCompletion call.","If constructing programmatically, always pass a model id."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if (!llm.model || typeof llm.model !== 'string')\n  throw new Error('DockerModelRunnerLLM.model is not set — pass a model id at construction.');","typeGuard":"function hasDmrModel(instance) {\n  return typeof instance?.model === 'string' && instance.model.trim().length > 0;\n}","tryCatchPattern":"try {\n  return await dmr.getChatCompletion(messages, { temperature });\n} catch (e) {\n  if (/is not valid or defined model/i.test(e.message))\n    throw new Error('Docker Model Runner has no model set — re-instantiate with DOCKER_MODEL_RUNNER_LLM_MODEL_PREF.');\n  throw e;\n}","preventionTips":["Always pass a model id at construction; do not clear this.model afterward.","If using a factory, assert this.model is a non-empty string before calling getChatCompletion."],"tags":["docker-model-runner","invalid-model","chat-completion","truthiness-check","local-llm"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}