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.

feat(warehouse_sources): repin Qualys VMDR sources off sunset 2.0 API (#86342)

Tom Owers4fab74c7a401
diff --git a/.agents/skills/warehouse-source-new-version/SKILL.md b/.agents/skills/warehouse-source-new-version/SKILL.md
index 3f1c40544da8..86e5493f73a1 100644
--- a/.agents/skills/warehouse-source-new-version/SKILL.md
+++ b/.agents/skills/warehouse-source-new-version/SKILL.md
@@ -65,7 +65,7 @@ Add it when any of these hold:
2. Add the old version to `deprecated_versions` with the vendor's announced sunset date (or `sunset_at=None` if none). Never deprecate `default_version` — flip the default to the new version in the same PR.
3. The in-product warning banner and API fields light up automatically from the metadata — zero per-source UI work.
4. **Deprecated is not migrated.** Existing pins move only when the vendor has announced the version will stop being served (a sunset/removal date). A deprecation without a sunset date is advisory: mark it, leave every existing pin on it fully supported, and write no migration — repinning working customers off a version the vendor still serves is exactly the silent version move the pinning framework exists to prevent. Two narrow cases still repin under an advisory (`sunset_at=None`) deprecation: the deprecated label resolves to a byte-identical request as the new default (a pure alias — no per-version dispatch — so the repin is not a move), or the vendor already errors on the old version (e.g. `410`/`406`) so leaving pins is worse than moving them. A source that sends a per-version header/URL for a version the vendor still serves is neither — stay advisory.
-5. Only for a sunsetting version: include a **written-not-run** migration script that repins affected `ExternalDataSource` rows (`api_version` column) from the deprecated version to the new one, plus any safe data/schema transforms. It must be idempotent and reviewable, and its reverse must be a no-op — repinned rows are indistinguishable from natively-created ones, so a blanket downgrade would clobber legitimate native pins. Repin only rows explicitly on the deprecated version: when the default is already the target (you are deprecating an old label without flipping the default in this PR), do not also repin NULL pins — they already resolve to the current default, so touching them is redundant churn — and leave other still-served deprecated versions alone. Where migration is lossy or unsafe — including when the new version needs credentials that can't be derived from the stored ones — do not script it: document the manual path in the PR. Do not execute migrations or backfills; humans review and run them.
+5. Only for a sunsetting version: include a **written-not-run** migration script that repins affected `ExternalDataSource` rows (`api_version` column) from the deprecated version to the new one, plus any safe data/schema transforms. It must be idempotent and reviewable, and its reverse must be a no-op — repinned rows are indistinguishable from natively-created ones, so a blanket downgrade would clobber legitimate native pins. Repin only rows explicitly on the deprecated version: when the default is already the target (you are deprecating an old label without flipping the default in this PR), do not also repin NULL pins — they already resolve to the current default, so touching them is redundant churn — and leave other still-served deprecated versions alone. Where migration is lossy or unsafe — including when the new version needs credentials that can't be derived from the stored ones — do not script it: document the manual path in the PR. When only a subset of rows is unsafe (the version diverges for one endpoint that needs a credential others don't), split the cohort: script the repin for the safe rows and exclude the unsafe ones by querying their schemas, documenting only that cohort as manual — don't drop the whole migration to manual because one endpoint can't move. Do not execute migrations or backfills; humans review and run them.
6. **Never touch `ExternalDataSchema.api_version` overrides** in migration scripts — they are user-managed by design. The schema-level deprecation warning covers them; the user migrates them from the schema's configuration page.
## Pinning semantics (do not break these)
diff --git a/products/warehouse_sources/backend/migrations/0148_repin_qualys_vmdr_api_version_4_0.py b/products/warehouse_sources/backend/migrations/0148_repin_qualys_vmdr_api_version_4_0.py
new file mode 100644
index 000000000000..a25b4715c66e
--- /dev/null
+++ b/products/warehouse_sources/backend/migrations/0148_repin_qualys_vmdr_api_version_4_0.py
@@ -0,0 +1,59 @@
+from django.db import migrations
+
+# Qualys sunset KnowledgeBase 2.0 on 2026-06-30 (End of Life), so source-level "2.0" pins must move
+# to "4.0". Most of the move is safe to script: the hosts, host_list_detection, and scans tables
+# send a byte-identical request on 2.0 and 4.0 (they stay on the FO API's own /api/2.0/ routes with
+# basic auth regardless of the source pin), so repinning those sources is not a version move on the
+# wire — only a relabel.
+#
+# The knowledge_base table is the exception: on 4.0 it authenticates with a gateway-minted JWT, which
+# needs a gateway URL the stored basic-auth credentials don't carry. A source whose knowledge_base
+# schema follows the source pin therefore can't be moved to 4.0 automatically — that repin is a
+# manual path (add a gateway URL, then repin), documented in the PR. Such sources are excluded here
+# and left on "2.0"; the version deprecation warning surfaces the pending migration.
+#
+# Only the source-level pin is touched. Schema-level `ExternalDataSchema.api_version` overrides are
+# user-managed by design (a customer intentionally pinned that schema) and are left alone — the
+# schema-level deprecation warning prompts the user to migrate those. A knowledge_base schema with
+# its own override does not follow the source pin, so it never blocks a source's repin.
+QUALYS_VMDR_SOURCE_TYPE = "QualysVmdr"
+QUALYS_VMDR_API_VERSION_2_0 = "2.0"
+QUALYS_VMDR_API_VERSION_4_0 = "4.0"
+
+
+def repin_qualys_vmdr_2_0_to_4_0(apps, schema_editor):
+ ExternalDataSource = apps.get_model("warehouse_sources", "ExternalDataSource")
+ ExternalDataSchema = apps.get_model("warehouse_sources", "ExternalDataSchema")
+
+ # Sources whose knowledge_base sync follows the source pin: moving them to 4.0 would need a
+ # gateway URL that isn't derivable from stored credentials, so hold them on 2.0 (manual path).
+ gateway_dependent_source_ids = (
+ ExternalDataSchema.objects.filter(
+ source__source_type=QUALYS_VMDR_SOURCE_TYPE,
+ name="knowledge_base",
+ should_sync=True,
+ api_version__isnull=True,
+ )
+ .exclude(deleted=True)
+ .values_list("source_id", flat=True)
+ )
+
+ # Idempotent: matches only explicit "2.0" pins, so a second run finds none. NULL pins already
+ # resolve to the "4.0" default (migration 0127 pinned any pre-existing NULL rows to "2.0"), so
+ # there is nothing to touch there.
+ ExternalDataSource.objects.filter(
+ source_type=QUALYS_VMDR_SOURCE_TYPE, api_version=QUALYS_VMDR_API_VERSION_2_0
+ ).exclude(id__in=gateway_dependent_source_ids).update(api_version=QUALYS_VMDR_API_VERSION_4_0)
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("warehouse_sources", "0147_add_kalshi_source"),
+ ]
+
+ operations = [
+ # Reverse is a no-op: once repinned, "4.0" rows are indistinguishable from natively-created
+ # ones, so a blanket downgrade would clobber legitimate "4.0" pins and move customers back
+ # onto the sunset "2.0" version.
+ migrations.RunPython(repin_qualys_vmdr_2_0_to_4_0, migrations.RunPython.noop, elidable=False),
+ ]
diff --git a/products/warehouse_sources/backend/migrations/max_migration.txt b/products/warehouse_sources/backend/migrations/max_migration.txt
index d62018afc473..1e5b3b0632ac 100644
--- a/products/warehouse_sources/backend/migrations/max_migration.txt
+++ b/products/warehouse_sources/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0147_add_kalshi_source
+0148_repin_qualys_vmdr_api_version_4_0
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/source.py
index abb6aafb7325..e9fcca2dbcb7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/source.py
@@ -47,9 +47,10 @@ class QualysVmdrSource(ResumableSource[QualysVmdrSourceConfig, QualysVmdrResumeC
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
supported_versions = QUALYS_VMDR_SUPPORTED_VERSIONS
default_version = QUALYS_VMDR_DEFAULT_VERSION
- # Qualys is retiring KnowledgeBase 2.0 (End of Service Dec 2025, End of Life Dec 2026).
+ # Qualys is retiring KnowledgeBase 2.0 (End of Support Dec 2025, End of Life June 2026); the
+ # sunset date is the End of Life, when Qualys stops serving the version.
deprecated_versions = (
- VersionDeprecation(version=QUALYS_VMDR_API_VERSION_2_0, sunset_at=datetime.date(2025, 12, 31)),
+ VersionDeprecation(version=QUALYS_VMDR_API_VERSION_2_0, sunset_at=datetime.date(2026, 6, 30)),
)
api_docs_url = "https://docs.qualys.com/en/vm/api/index.htm"
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/tests/test_qualys_vmdr_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/tests/test_qualys_vmdr_source.py
index 63427501e990..32fbb8ebd89d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/tests/test_qualys_vmdr_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/tests/test_qualys_vmdr_source.py
@@ -116,7 +116,7 @@ class TestQualysVmdrSource:
# New sources start on 4.0; 2.0 carries the vendor's announced sunset date and 4.0 is clean.
assert self.source.default_version == "4.0"
deprecation = self.source.get_version_deprecation("2.0")
- assert deprecation is not None and deprecation.sunset_at == datetime.date(2025, 12, 31)
+ assert deprecation is not None and deprecation.sunset_at == datetime.date(2026, 6, 30)
assert self.source.get_version_deprecation("4.0") is None
@pytest.mark.parametrize(