FujiwaraChoki/MoneyPrinterV2 · error · ValueError

Affiliate link is invalid. Expected a full URL, got: {self.a

Error message

Affiliate link is invalid. Expected a full URL, got: {self.affiliate_link}

What it means

Raised in AFM.__init__ when the affiliate link does not parse as an absolute http(s) URL. The class needs a full URL (scheme + host) to later append tracking parameters, so relative or malformed links are rejected.

Source

Thrown at src/classes/AFM.py:75

        # Set the profile path
        self.options.add_argument("-profile")
        self.options.add_argument(fp_profile_path)

        # Set the service
        self.service: Service = Service(GeckoDriverManager().install())

        # Initialize the browser
        self.browser: webdriver.Firefox = webdriver.Firefox(
            service=self.service, options=self.options
        )

        # Set the affiliate link
        self.affiliate_link: str = affiliate_link

        parsed_link = urlparse(self.affiliate_link)
        if parsed_link.scheme not in ["http", "https"] or not parsed_link.netloc:
            raise ValueError(
                f"Affiliate link is invalid. Expected a full URL, got: {self.affiliate_link}"
            )

        # Set the Twitter account UUID
        self.account_uuid: str = twitter_account_uuid

        # Set the Twitter account nickname
        self.account_nickname: str = account_nickname

        # Set the Twitter topic
        self.topic: str = topic

        # Scrape the product information
        self.scrape_product_information()

    def scrape_product_information(self) -> None:
        """
        This method will be used to scrape the product

View on GitHub (pinned to 5192af8eca)

Solutions

  1. Prepend 'https://' when the scheme is missing
  2. Trim whitespace and validate the link at its source (config/UI) before constructing AFM
  3. Reject non-http(s) schemes like mailto: or ftp: early

Example fix

// before
afm = AFM(affiliate_link="example.com/?ref=123", ...)

// after
link = affiliate_link.strip()
if not link.startswith(("http://", "https://")):
    link = "https://" + link
afm = AFM(affiliate_link=link, ...)
Defensive patterns

Strategy: validation

Validate before calling

from urllib.parse import urlparse

link = (affiliate_link or "").strip()
if not link.startswith(("http://", "https://")):
    link = "https://" + link
parsed = urlparse(link)
if parsed.scheme not in ("http", "https") or not parsed.netloc:
    raise ValueError(f"Invalid affiliate link: {link!r}")

Type guard

from urllib.parse import urlparse

def is_full_http_url(link: str) -> bool:
    try:
        p = urlparse((link or "").strip())
    except ValueError:
        return False
    return p.scheme in ("http", "https") and bool(p.netloc)

Prevention

When it happens

Trigger: Passing affiliate_link like 'example.com/?ref=1' (no scheme), 'ftp://...', a bare path '/ref/123', or an empty/None-coerced string.

Common situations: Links scraped or typed without the https:// prefix, links read from a spreadsheet/config that stripped the scheme, or trailing whitespace breaking urlparse.

Related errors


AI-assisted analysis of FujiwaraChoki/MoneyPrinterV2@5192af8eca (2026-08-28). Data as JSON: /api/errors/deb9526bd1e9a641. Report an issue: GitHub.