{"record":{"id":"9e4dda922981ef0b","repo":"invoke-ai/InvokeAI","slug":"source-url-must-be-an-http-or-https-url-9e4dda","errorCode":null,"errorMessage":"source_url must be an http or https URL","messagePattern":"source_url must be an http or https URL","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/base.py","lineNumber":93,"sourceCode":"    )\n    source_api_response: str | None = Field(\n        default=None,\n        description=\"The original API response from the source, as stringified JSON.\",\n    )\n    source_url: str | None = Field(\n        default=None,\n        description=\"Optional URL for the model (e.g. download page or model page).\",\n    )\n\n    @field_validator(\"source_url\", mode=\"before\")\n    @classmethod\n    def validate_source_url(cls, v: Any) -> str | None:\n        if v is None or v == \"\":\n            return None\n        if not isinstance(v, str):\n            raise ValueError(\"source_url must be a string\")\n        if not v.startswith((\"https://\", \"http://\")):\n            raise ValueError(\"source_url must be an http or https URL\")\n        return v\n\n    cover_image: str | None = Field(\n        default=None,\n        description=\"Url for image to preview model\",\n    )\n\n    CONFIG_CLASSES: ClassVar[set[Type[\"Config_Base\"]]] = set()\n    \"\"\"Set of all non-abstract subclasses of Config_Base, for use during model probing. In other words, this is the set\n    of all known model config types.\"\"\"\n\n    model_config = ConfigDict(\n        validate_assignment=True,\n        json_schema_serialization_defaults_required=True,\n        json_schema_mode_override=\"serialization\",\n    )\n\n    @classmethod","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/base.py#L75-L111","documentation":"The same validate_source_url validator raises ValueError when the string does not start with 'https://' or 'http://'. InvokeAI requires source_url to be an absolute HTTP(S) URL.","triggerScenarios":"Assigning source_url like 'huggingface.co/repo/model', 'file:///path', a bare local path, or a URL with leading whitespace so startswith() fails.","commonSituations":"Storing a local file path as the source; forgetting the scheme on a HF/Civitai URL; copying a URL with a leading space or markdown artifact.","solutions":["Prefix the value with 'https://' (e.g. 'https://huggingface.co/...') before saving the config.","Strip whitespace: v.strip() and re-check the scheme.","Use None instead of a path if the model came from disk and has no web source."],"exampleFix":"// before\nconfig = {'source_url': 'huggingface.co/black-forest-labs/FLUX.1-schnell'}\n// after\nconfig = {'source_url': 'https://huggingface.co/black-forest-labs/FLUX.1-schnell'}","handlingStrategy":"validation","validationCode":"def ensure_url(v: str | None) -> str | None:\n    if v is None or v == '':\n        return None\n    v = v.strip()\n    if not v.startswith(('https://', 'http://')):\n        v = 'https://' + v\n    return v","typeGuard":"def is_http_url(v: object) -> TypeGuard[str]:\n    return isinstance(v, str) and v.startswith(('https://', 'http://'))","tryCatchPattern":"try:\n    config = ModelConfigBase(**cfg)\nexcept ValueError as e:\n    if 'http or https URL' in str(e):\n        cfg['source_url'] = 'https://' + str(cfg['source_url']).lstrip()\n        config = ModelConfigBase(**cfg)\n    else:\n        raise","preventionTips":["Store full URLs including scheme when recording model sources.","Normalize with urllib.parse (urlparse to check scheme in {'http','https'}) before saving.","Use None for local-only models instead of a file path in source_url."],"tags":["invokeai","pydantic","validation","url"],"backgroundTag":"invalid-url-format","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}