{"record":{"id":"df463e9a9606a72b","repo":"flarum/framework","slug":"provided-avatar-url-must-be-a-valid-uri","errorCode":null,"errorMessage":"Provided avatar URL must be a valid URI.","messagePattern":"Provided avatar URL must be a valid URI\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":422,"severity":"error","filePath":"framework/core/src/Api/Resource/UserResource.php","lineNumber":511,"sourceCode":"            $this->avatarUploader->uploadPresized($user, $image1x, $image2x, $image3x);\n        } else {\n            $image = $this->imageManager->read($urlContents);\n\n            $this->avatarUploader->upload($user, $image);\n        }\n    }\n\n    /**\n     * @throws ValidationException\n     */\n    private function assertValidAvatarUrl(string $url): void\n    {\n        $urlValidator = $this->validation->make(compact('url'), [\n            'url' => 'required|active_url',\n        ]);\n\n        if ($urlValidator->fails()) {\n            throw new ValidationException([\n                'avatar_url' => 'Provided avatar URL must be a valid URI.',\n            ]);\n        }\n\n        $scheme = parse_url($url, PHP_URL_SCHEME);\n\n        if (! in_array($scheme, ['http', 'https'])) {\n            throw new ValidationException([\n                'avatar_url' => \"Provided avatar URL must have scheme http or https. Scheme provided was $scheme.\",\n            ]);\n        }\n    }\n\n    private function readAvatarFromUrl(string $url): ?\\Intervention\\Image\\Interfaces\\ImageInterface\n    {\n        $contents = $this->retrieveAvatarFromUrl($url);\n\n        if ($contents === null || ! $this->withinMaxResolution($contents)) {","sourceCodeStart":493,"sourceCodeEnd":529,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/framework/core/src/Api/Resource/UserResource.php#L493-L529","documentation":"Validation helper guard in UserResource::assertValidAvatarUrl: the avatar_url supplied to uploadAvatarFromUrl failed Laravel's 'required|active_url' rule, so it is not a resolvable URI and cannot be downloaded to generate an avatar. The generic sentinel input at fault is the url string passed by the caller.","triggerScenarios":"Thrown at framework/core/src/Api/Resource/UserResource.php:511 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a fully qualified, resolvable URL (e.g. https://example.com/avatar.png) as avatar_url","Fix typos, missing scheme, or unreachable hosts in the provided URL","Surface the ValidationException errors map (avatar_url) to the client so it can correct the input"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4b939f685389bfe8a380e9e28ddf305a1c66950c","analyzedAt":"2026-09-15T18:09:20.879Z","contentChangedAt":"2026-09-15T18:09:20.879Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}