{"record":{"id":"f905cd0c63b16ef6","repo":"different-ai/openwork","slug":"model-name-is-required","errorCode":null,"errorMessage":"Model name is required.","messagePattern":"Model name is required\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/domains/settings/ollama-config.tsx","lineNumber":175,"sourceCode":"      }\n    }\n    return true;\n  } catch (error) {\n    onProgress({ status: `Pull failed: ${error instanceof Error ? error.message : String(error)}` });\n    return false;\n  }\n}\n\nfunction usePullOllamaModel(options: { onSuccess?: (model: string) => void } = {}) {\n  const queryClient = useQueryClient();\n  const [progress, setProgress] = useState<PullProgressState | null>(null);\n\n  const { mutateAsync: pullModel, isPending: isPulling } = useMutation({\n    mutationFn: async (modelName: string) => {\n      const model = modelName.trim();\n      \n      if (!model) {\n        throw new Error(\"Model name is required.\");\n      }\n\n      let latestProgress: PullProgressUpdate = { status: \"Starting pull...\" };\n      const updateProgress = (update: PullProgressUpdate) => {\n        latestProgress = update;\n        setProgress((current) => ({\n          modelName: model,\n          status: update.status,\n          completed: update.completed ?? current?.completed,\n          total: update.total ?? current?.total,\n        }));\n      };\n\n      updateProgress(latestProgress);\n      const ok = await pullOllamaModel(model, updateProgress);\n\n      if (!ok) {\n        if (latestProgress.status === \"Starting pull...\") {","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/domains/settings/ollama-config.tsx#L157-L193","documentation":"usePullOllamaModel is a React Query mutation hook that wraps the Ollama model pull API. Before calling the backend it trims the user-supplied model name and throws this error when the trimmed value is empty, because Ollama cannot pull a model with no name. It is a client-side guard so an obviously invalid request never reaches the server.","triggerScenarios":"Calling pullModel(\"\") or pullModel(\"   \") — a whitespace-only string — from the Ollama settings UI, typically when the model name input is empty and the user clicks Pull.","commonSituations":"User clicks the pull button without typing a model name; a form's default value is an empty string; a bound input loses its value; automation/scripts invoke pullModel with an unset variable.","solutions":["Type a valid Ollama model name (e.g. \"llama3.2\") into the input before pulling","Guard the call site: only invoke pullModel when the trimmed input is non-empty","Disable the Pull button while the name field is empty"],"exampleFix":"// before\npullModel(modelName);\n// after\nif (!modelName.trim()) return;\npullModel(modelName.trim());","handlingStrategy":"validation","validationCode":"const trimmed = modelName.trim();\nif (!trimmed) throw new Error(\"Model name is required.\");\npullModel(trimmed);","typeGuard":"const hasModelName = (v: string): v is string => v.trim().length > 0;","tryCatchPattern":"try {\n  await pullModel(name.trim());\n} catch (e) {\n  if (e.message === \"Model name is required.\") showInputError(\"Enter a model name\");\n  else throw e;\n}","preventionTips":["Always trim and check non-empty before pulling","Disable the Pull button while the input is empty","Add a required-field validation to the form"],"tags":["ollama","validation","empty-input"],"backgroundTag":"missing-required-argument","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}