{"record":{"id":"97010a3c4c9a1e5b","repo":"octobercms/october","slug":"please-specify-a-valid-url","errorCode":null,"errorMessage":"Please specify a valid URL","messagePattern":"Please specify a valid URL","errorType":"validation","errorClass":"October\\Rain\\Exception\\ValidationException","httpStatus":null,"severity":"warning","filePath":"modules/system/models/SiteDefinition.php","lineNumber":129,"sourceCode":"            'name' => 'Primary Site',\n            'code' => 'english',\n            'is_primary' => true,\n            'is_enabled' => true,\n            'is_enabled_edit' => true,\n            'group_id' => null,\n            'group' => null,\n        ];\n        $site->syncOriginal();\n        return $site;\n    }\n\n    /**\n     * beforeValidate\n     */\n    public function beforeValidate()\n    {\n        if ($this->is_custom_url && !Url::isValidUrl($this->app_url)) {\n            throw new ValidationException(['app_url' => __(\"Please specify a valid URL\")]);\n        }\n\n        if ($this->is_prefixed && (substr($this->route_prefix, 0, 1) !== '/' || $this->route_prefix === '/')) {\n            throw new ValidationException(['route_prefix' => __(\"Route prefix must start with a forward slash (/)\")]);\n        }\n\n        if ($this->is_host_restricted && !$this->isAllowHostsValid()) {\n            throw new ValidationException(['allow_hosts' => __(\"Please specify a valid hostname\")]);\n        }\n\n        $this->fallback_locale = $this->getFallbackLocale($this->locale);\n    }\n\n    /**\n     * getFallbackLocale attempts to extract the fallback language from the locale.\n     * @return string\n     */\n    protected function getFallbackLocale($locale)","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/system/models/SiteDefinition.php#L111-L147","documentation":"The multisite SiteDefinition model validates in beforeValidate(): when a site is configured with a custom URL (is_custom_url), app_url must pass Url::isValidUrl() (scheme + host). Otherwise a ValidationException is thrown against the app_url field, so the backend site form redisplays with the field error instead of saving.","triggerScenarios":"Saving a site with is_custom_url enabled and app_url lacking the scheme ('example.com', 'example.com/de'), empty, or otherwise malformed (spaces, smart quotes, invalid host).","commonSituations":"Entering a bare domain in the site form; pasting URLs with whitespace or unicode quotes; scripts provisioning sites with unnormalized URLs.","solutions":["Enter the full absolute URL including scheme, e.g. https://example.com (a path suffix is allowed)","Disable the custom URL option if the site should derive its URL from the primary domain instead","When saving programmatically, set app_url from a normalized value (rtrim scheme+host) before save()"],"exampleFix":"# before\napp_url: \"example.com/de\"\n\n# after\napp_url: \"https://example.com/de\"","handlingStrategy":"validation","validationCode":"if ($site->is_custom_url && !\\Url::isValidUrl($site->app_url)) {\n    // block save and prompt for a full URL such as https://example.com\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the scheme (https://) in custom site URLs","Normalize pasted URLs in the form (trim whitespace, add scheme) before submit","Turn off custom URL when the site can derive its URL from the primary domain"],"tags":["multisite","site","validation","url"],"backgroundTag":"invalid-url-format","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}