{"record":{"id":"0f0ff0c728584e38","repo":"oobabooga/textgen","slug":"no-model-specified","errorCode":null,"errorMessage":"No model specified.","messagePattern":"No model specified\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"modules/utils.py","lineNumber":109,"sourceCode":"        if len(get_available_models()) == 0:\n            logger.error(f\"No model is loaded. To get started: 1) Place a GGUF file in your {shared.user_data_dir}/models folder, 2) Go to the Model tab and select it\")\n            return False, f\"No model is loaded. Place a GGUF model in your {shared.user_data_dir}/models folder, then select it in the Model tab.\"\n        else:\n            error_msg = \"No model is loaded. Please select one in the Model tab.\"\n            logger.error(error_msg)\n            return False, error_msg\n\n    return True, None\n\n\ndef resolve_model_path(model_name_or_path, image_model=False):\n    \"\"\"\n    Resolves a model path, checking for a direct path\n    before the default models directory.\n    \"\"\"\n\n    if model_name_or_path is None:\n        raise FileNotFoundError(\"No model specified.\")\n\n    path_candidate = Path(model_name_or_path)\n    if path_candidate.exists():\n        return path_candidate\n    elif image_model:\n        return Path(f'{shared.args.image_model_dir}/{model_name_or_path}')\n    else:\n        return Path(f'{shared.args.model_dir}/{model_name_or_path}')\n\n\ndef get_available_models():\n    # Get all GGUF files\n    gguf_files = get_available_ggufs()\n\n    # Filter out non-first parts of multipart GGUF files\n    filtered_gguf_files = []\n    for gguf_path in gguf_files:\n        filename = os.path.basename(gguf_path)","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/oobabooga/textgen/blob/ed888c71f221df552750e1834b3654abab8ae345/modules/utils.py#L91-L127","documentation":"resolve_model_path() raises FileNotFoundError('No model specified.') when model_name_or_path is None. The resolver cannot guess a model: it first checks whether the argument is an existing filesystem path, and only then falls back to joining a models directory with the name. A None argument short-circuits both branches immediately.","triggerScenarios":"Calling model loading APIs with model_name_or_path=None — typically when a CLI flag (--model) or UI model selector was left empty, or when a caller reads the model id from config/shared state that was never populated (e.g. shared.model_name unset at load time).","commonSituations":"Fresh install where no default model is set; a script or extension calls load_model with a variable that failed earlier and silently became None; switching between model dirs where the previous value is cleared but not replaced; API call with the model field omitted.","solutions":["Pass an explicit model name or path: set the --model CLI argument or select a model in the UI before loading.","If calling programmatically, check the variable is not None before calling and fail early with your own clearer message.","Verify shared.args.model_dir contains the model folder you named, since a non-path name is resolved relative to that directory.","For image models, confirm image_model_dir is configured when relying on name-based resolution."],"exampleFix":"# before\npath = resolve_model_path(shared.model_name)  # shared.model_name is None -> crash\n\n# after\nif not shared.model_name:\n    raise SystemExit('No model selected. Pass --model <name-or-path> or pick one in the UI.')\npath = resolve_model_path(shared.model_name)","handlingStrategy":"validation","validationCode":"def has_model(name) -> bool:\n    return name is not None and (Path(name).exists() or (shared.args.model_dir / name).exists())\n\n# before loading:\nif not shared.model_name:\n    raise SystemExit('Select a model first: --model <name-or-path>')","typeGuard":"def is_model_ref(value) -> bool:\n    return isinstance(value, str) and len(value.strip()) > 0","tryCatchPattern":"try:\n    path = resolve_model_path(model_name)\nexcept FileNotFoundError as e:\n    if 'No model specified' in str(e):\n        raise SystemExit('No model selected. Pass --model or choose one in the UI.') from e\n    raise","preventionTips":["Fail fast at startup: assert the model variable is a non-empty string before any load call.","Set an explicit default model in your launch command/config so an unset flag never reaches the loader.","Log which model name is being resolved right before loading to catch None early."],"tags":["model-loading","configuration","startup"],"backgroundTag":null,"analyzedSha":"ed888c71f221df552750e1834b3654abab8ae345","analyzedAt":"2026-08-15T05:24:21.000Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}