flarum/framework · error · ValidationException

Provided avatar URL must be a valid URI.

Error message

Provided avatar URL must be a valid URI.

What it means

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.

Solutions

  1. Pass a fully qualified, resolvable URL (e.g. https://example.com/avatar.png) as avatar_url
  2. Fix typos, missing scheme, or unreachable hosts in the provided URL
  3. Surface the ValidationException errors map (avatar_url) to the client so it can correct the input
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at framework/core/src/Api/Resource/UserResource.php:511 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of flarum/framework@4b939f6853 (2026-09-15). Data as JSON: /api/errors/df463e9a9606a72b. Report an issue: GitHub.

Appendix: source

Thrown at framework/core/src/Api/Resource/UserResource.php:511

            $this->avatarUploader->uploadPresized($user, $image1x, $image2x, $image3x);
        } else {
            $image = $this->imageManager->read($urlContents);

            $this->avatarUploader->upload($user, $image);
        }
    }

    /**
     * @throws ValidationException
     */
    private function assertValidAvatarUrl(string $url): void
    {
        $urlValidator = $this->validation->make(compact('url'), [
            'url' => 'required|active_url',
        ]);

        if ($urlValidator->fails()) {
            throw new ValidationException([
                'avatar_url' => 'Provided avatar URL must be a valid URI.',
            ]);
        }

        $scheme = parse_url($url, PHP_URL_SCHEME);

        if (! in_array($scheme, ['http', 'https'])) {
            throw new ValidationException([
                'avatar_url' => "Provided avatar URL must have scheme http or https. Scheme provided was $scheme.",
            ]);
        }
    }

    private function readAvatarFromUrl(string $url): ?\Intervention\Image\Interfaces\ImageInterface
    {
        $contents = $this->retrieveAvatarFromUrl($url);

        if ($contents === null || ! $this->withinMaxResolution($contents)) {

View on GitHub (pinned to 4b939f6853)