discourse/discourse · error · Discourse::InvalidParameters

url

Error message

url

What it means

A guard in FileHelper.download: raised as Discourse::InvalidParameters.new(:url) when the url argument (after prepending 'https:' to protocol-relative URLs) does not match %r{\Ahttps?://}. The downloader refuses non-HTTP(S) schemes such as ftp:, file:, data:, or relative paths. The at-fault input is the url parameter.

Solutions

  1. Pass a fully qualified http:// or https:// URL
  2. Normalize scheme-relative //host/path URLs before calling, or rely on the built-in https: prefixing
  3. Reject/repair malformed URLs at the caller before attempting the download
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/file_helper.rb:76 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of discourse/discourse@1b2d7253e8 (2026-08-26). Data as JSON: /api/errors/b3d18edea2904da3. Report an issue: GitHub.

Appendix: source

Thrown at lib/file_helper.rb:76

  class FakeIO
    attr_accessor :status
  end

  def self.download(
    url,
    max_file_size:,
    tmp_file_name:,
    follow_redirect: false,
    read_timeout: 5,
    skip_rate_limit: false,
    verbose: false,
    validate_uri: true,
    retain_on_max_file_size_exceeded: false,
    include_port_in_host_header: false,
    extra_headers: {}
  )
    url = "https:" + url if url.start_with?("//")
    raise Discourse::InvalidParameters.new(:url) unless url =~ %r{\Ahttps?://}

    tmp = nil

    fd =
      FinalDestination.new(
        url,
        max_redirects: follow_redirect ? 5 : 0,
        skip_rate_limit: skip_rate_limit,
        verbose: verbose,
        validate_uri: validate_uri,
        timeout: read_timeout,
        include_port_in_host_header: include_port_in_host_header,
        headers: extra_headers,
      )

    fd.get do |response, chunk, uri|
      if tmp.nil?
        # error handling

View on GitHub (pinned to 1b2d7253e8)