: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(oauth): stop persisting cimd_metadata_url (#86762)
Rafael Audibert1a451bd5a068
diff --git a/posthog/admin/admins/oauth_admin.py b/posthog/admin/admins/oauth_admin.pyindex 7a91a55ba882..d68a1a3aced3 100644--- a/posthog/admin/admins/oauth_admin.py+++ b/posthog/admin/admins/oauth_admin.py@@ -220,7 +220,7 @@ class OAuthApplicationAdmin(admin.ModelAdmin): # nosemgrep: admin-modeladmin-ne"is_provisioning_partner",ProvisioningCapabilityFilter,)- search_fields = ("name", "client_id", "cimd_metadata_url", "user__email", "organization__name")+ search_fields = ("name", "client_id", "user__email", "organization__name")autocomplete_fields = ("user", "organization")ordering = ("name",)actions = ("revoke_all_sessions", "regenerate_client_secret")@@ -293,7 +293,7 @@ class OAuthApplicationAdmin(admin.ModelAdmin): # nosemgrep: admin-modeladmin-nedef get_readonly_fields(self, request, obj=None):if obj:- readonly = ["id", "client_id", "is_dcr_client", "is_cimd_client", "cimd_metadata_url"]+ readonly = ["id", "client_id", "is_dcr_client", "is_cimd_client"]if obj.is_cimd_client:# A CIMD client's scope ceiling is derived from its own metadata document and# re-applied on every refresh, so a manual edit here would be silently reverted.@@ -354,7 +354,7 @@ class OAuthApplicationAdmin(admin.ModelAdmin): # nosemgrep: admin-modeladmin-ne"CIMD",{"classes": ("collapse",),- "fields": ("cimd_metadata_url", "cimd_metadata_last_fetched"),+ "fields": ("cimd_metadata_last_fetched",),},),)diff --git a/posthog/api/oauth/cimd.py b/posthog/api/oauth/cimd.pyindex 31721fb15a15..d0bfe3649a6b 100644--- a/posthog/api/oauth/cimd.py+++ b/posthog/api/oauth/cimd.py@@ -682,7 +682,6 @@ def _create_cimd_application(algorithm="RS256",skip_authorization=False,is_cimd_client=True,- cimd_metadata_url=url,cimd_metadata_last_fetched=timezone.now(),logo_uri=logo_uri,organization=verification.organization if verification else None,diff --git a/posthog/api/oauth/test_cimd.py b/posthog/api/oauth/test_cimd.pyindex 32d2cc6b2675..d840028d3dc2 100644--- a/posthog/api/oauth/test_cimd.py+++ b/posthog/api/oauth/test_cimd.py@@ -326,7 +326,6 @@ class TestFetchAndUpsertCimdApplication(APIBaseTest):self.assertTrue(app.is_cimd_client)self.assertFalse(app.is_dcr_client)self.assertEqual(app.client_id, VALID_CIMD_URL)- self.assertEqual(app.cimd_metadata_url, VALID_CIMD_URL)self.assertEqual(app.name, "Test MCP Client")self.assertEqual(app.redirect_uris, "http://127.0.0.1:3000/callback")self.assertEqual(app.logo_uri, "https://example.com/logo.png")diff --git a/posthog/migrations/1327_untrack_cimd_metadata_url.py b/posthog/migrations/1327_untrack_cimd_metadata_url.pynew file mode 100644index 000000000000..6c4eefb8c8fe--- /dev/null+++ b/posthog/migrations/1327_untrack_cimd_metadata_url.py@@ -0,0 +1,27 @@+from django.db import migrations+++class Migration(migrations.Migration):+ """Stop tracking cimd_metadata_url in Django state.++ client_id holds the same metadata-document URL since 1324, and no code resolves a CIMD+ client through this column any more.++ State-only: the column stays in Postgres so a rollback to the previous release still+ finds it, and so no read of a dropped column can 500 during the deploy window. Drop the+ column itself in a later release, once no deployed code references it.+ """++ dependencies = [("posthog", "1326_drop_legacy_provisioning_columns")]++ operations = [+ migrations.SeparateDatabaseAndState(+ state_operations=[+ migrations.RemoveField(+ model_name="oauthapplication",+ name="cimd_metadata_url",+ ),+ ],+ database_operations=[],+ ),+ ]diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txtindex 83f685cbdd79..96baef4701fe 100644--- a/posthog/migrations/max_migration.txt+++ b/posthog/migrations/max_migration.txt@@ -1 +1 @@-1326_drop_legacy_provisioning_columns+1327_untrack_cimd_metadata_urldiff --git a/posthog/models/oauth.py b/posthog/models/oauth.pyindex d6992e1316db..2d897dc02f89 100644--- a/posthog/models/oauth.py+++ b/posthog/models/oauth.py@@ -191,16 +191,6 @@ class OAuthApplication(ModelActivityMixin, AbstractApplication): # type: ignoreverbose_name="Is CIMD client",help_text="True if this client was registered via Client ID Metadata Document (CIMD)",)- # Superseded by client_id, which now holds this same URL. Nothing resolves a client- # through it any more; it stays written on create so a rollback to code that does keeps- # working, and is dropped once that window closes.- cimd_metadata_url: models.URLField = models.URLField(- max_length=2048,- null=True,- blank=True,- unique=True,- help_text="The URL used as client_id for CIMD clients. Must match the client_id in the metadata document.",- )cimd_metadata_last_fetched: models.DateTimeField = models.DateTimeField(null=True, blank=True, help_text="When the CIMD metadata was last successfully fetched")