Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(google-search-console): match property URLs case-insensitively by scheme and host (#65125)

Tom Owersbb8aa6bc47f2
diff --git a/posthog/temporal/data_imports/sources/google_search_console/google_search_console.py b/posthog/temporal/data_imports/sources/google_search_console/google_search_console.py
index 5aa86b2e59f8..c24ca4f494e6 100644
--- a/posthog/temporal/data_imports/sources/google_search_console/google_search_console.py
+++ b/posthog/temporal/data_imports/sources/google_search_console/google_search_console.py
@@ -4,7 +4,7 @@ import threading
import dataclasses
import collections.abc
from typing import Any
-from urllib.parse import parse_qs, quote, unquote, urlparse
+from urllib.parse import parse_qs, quote, unquote, urlparse, urlunparse
from django.conf import settings
from django.db import close_old_connections
@@ -127,9 +127,15 @@ def normalize_site_url(raw: str) -> str:
if "%" in site:
site = unquote(site).strip()
- # URL-prefix properties are canonically stored with a trailing slash.
- if site.startswith(("http://", "https://")) and not site.endswith("/"):
- site = site + "/"
+ # URL-prefix properties are canonically stored with a lowercase scheme and host and a
+ # trailing slash. Schemes and hostnames are case-insensitive, so a value like
+ # "Https://Example.com/" never matches Google's lowercase form on an exact lookup — lower
+ # both (leaving the path alone, which can be case-sensitive) and add the trailing slash.
+ parsed = urlparse(site)
+ if parsed.scheme.lower() in ("http", "https"):
+ site = urlunparse(parsed._replace(scheme=parsed.scheme.lower(), netloc=parsed.netloc.lower()))
+ if not site.endswith("/"):
+ site = site + "/"
return site
diff --git a/posthog/temporal/data_imports/sources/google_search_console/tests/test_google_search_console.py b/posthog/temporal/data_imports/sources/google_search_console/tests/test_google_search_console.py
index 7cce5dff18e2..0d5cff02b7d2 100644
--- a/posthog/temporal/data_imports/sources/google_search_console/tests/test_google_search_console.py
+++ b/posthog/temporal/data_imports/sources/google_search_console/tests/test_google_search_console.py
@@ -441,6 +441,11 @@ def test_throttle_spaces_requests_per_site(monkeypatch):
# URL-prefix property missing its trailing slash.
("https://agentic30.app", "https://agentic30.app/"),
("https://docebo.com", "https://docebo.com/"),
+ # Capitalized scheme/host — Google stores both lowercase, so an exact match needs them lowered.
+ ("Https://www.veteranpcs.com/", "https://www.veteranpcs.com/"),
+ ("HTTPS://Example.com", "https://example.com/"),
+ # Path case is preserved — it can be significant for a URL-prefix property.
+ ("Https://example.com/Blog", "https://example.com/Blog/"),
# Surrounding whitespace.
(" https://example.com/ ", "https://example.com/"),
# The full Search Console UI URL — the property lives in resource_id.