instructure/canvas-lms · error · ArgumentError

assets_url for '# ' must be a valid URL

Error message

assets_url for '#{app}' must be a valid URL

What it means

Raised by validate_params! when URI.parse(assets_url) raises URI::InvalidURIError, meaning the value for an app is not a parseable URL (missing scheme, illegal characters, malformed). It is re-raised as ArgumentError with a per-app message.

Solutions

  1. Send a fully qualified absolute URL including scheme (https://host/path)
  2. Trim whitespace/newlines from the value before sending
  3. URI-escape any special characters in the path
  4. Validate with URI.parse (or equivalent) client-side before submitting

Example fix

// before
{ override: { 'k5': 'cdn.instructure.com/k5' } }
// after
{ override: { 'k5': 'https://cdn.instructure.com/k5' } }
Defensive patterns

Strategy: validation

Validate before calling

let u; try { u = new URL(assets_url); } catch { throw new Error(`${app} assets_url must be absolute https URL`); }

Type guard

const isAbsoluteUrl = (s) => { try { const u = new URL(s); return !!u.protocol && !!u.hostname; } catch { return false; } };

Try / catch

begin
  validate_params!
rescue ArgumentError => e
  render json: { error: e.message }, status: :bad_request
end

Prevention

When it happens

Trigger: Passing a bare hostname without scheme, an empty-ish string with spaces or control characters, or a truncated URL in params[:override][app]; JSON values that got mangled (e.g. missing https://).

Common situations: Hand-edited config/scripts dropping the https:// prefix; shell quoting stripping characters; trailing newlines from environment variables copied into the payload.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/c4dfa74a7fe5dad6. Report an issue: GitHub.

Appendix: source

Thrown at app/controllers/microfrontends_release_tag_override_controller.rb:78

    unless override_params.respond_to?(:each)
      raise ArgumentError, "override parameter must be a hash"
    end

    override_params.each do |app, assets_url|
      next if assets_url.blank?

      unless SUPPORTED_APPS.include?(app)
        raise ArgumentError, "app '#{app}' must be one of: #{SUPPORTED_APPS.join(", ")}"
      end

      begin
        uri = URI.parse(assets_url)
        unless ALLOWED_HOSTS.include?(uri.host)
          raise ArgumentError, "assets_url host for '#{app}' must be one of: #{ALLOWED_HOSTS.join(", ")}"
        end
      rescue URI::InvalidURIError
        raise ArgumentError, "assets_url for '#{app}' must be a valid URL"
      end
    end
  end
end

View on GitHub (pinned to 1c9f0bb801)