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(oauth): widen OAuthApplication.client_id to hold CIMD URLs (#86099)

Rafael Audibertbaea6b37e8ca
diff --git a/frontend/src/generated/core/api.schemas.ts b/frontend/src/generated/core/api.schemas.ts
index bffb616c39f9..1c22fc87ec64 100644
--- a/frontend/src/generated/core/api.schemas.ts
+++ b/frontend/src/generated/core/api.schemas.ts
@@ -416,7 +416,7 @@ export interface OrganizationOAuthApplicationApi {
readonly id: string
/** @maxLength 255 */
name?: string
- /** @maxLength 100 */
+ /** @maxLength 2048 */
client_id?: string
readonly redirect_uris_list: readonly string[]
/** True if this application has been verified by PostHog */
diff --git a/posthog/migrations/1311_alter_oauthapplication_client_id.py b/posthog/migrations/1311_alter_oauthapplication_client_id.py
new file mode 100644
index 000000000000..e509625befec
--- /dev/null
+++ b/posthog/migrations/1311_alter_oauthapplication_client_id.py
@@ -0,0 +1,24 @@
+# Generated by Django 5.2.17 on 2026-08-19 23:20
+
+from django.db import migrations, models
+
+import oauth2_provider.generators
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1310_provisioning_rate_limit_overrides"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="oauthapplication",
+ name="client_id",
+ field=models.CharField(
+ db_index=True,
+ default=oauth2_provider.generators.generate_client_id,
+ max_length=2048,
+ unique=True,
+ ),
+ ),
+ ]
diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txt
index f617d6390361..2de2841afe78 100644
--- a/posthog/migrations/max_migration.txt
+++ b/posthog/migrations/max_migration.txt
@@ -1 +1 @@
-1310_provisioning_rate_limit_overrides
+1311_alter_oauthapplication_client_id
diff --git a/posthog/models/oauth.py b/posthog/models/oauth.py
index 0c817d03097a..2a966ed1d64a 100644
--- a/posthog/models/oauth.py
+++ b/posthog/models/oauth.py
@@ -14,6 +14,7 @@ from django.dispatch import receiver
from django.utils import timezone
import structlog
+from oauth2_provider.generators import generate_client_id
from oauth2_provider.models import (
AbstractAccessToken,
AbstractApplication,
@@ -79,6 +80,13 @@ def is_loopback_host(hostname: str | None) -> bool:
class OAuthApplication(ModelActivityMixin, AbstractApplication): # type: ignore[django-manager-missing]
id: models.UUIDField = models.UUIDField(primary_key=True, default=UUIDT, editable=False)
+ # Overrides the abstract base's max_length=100 so the column can hold a CIMD
+ # metadata-document URL as the client's identifier (sized to match cimd_metadata_url).
+ # Non-CIMD clients keep the generated opaque value.
+ client_id: models.CharField = models.CharField(
+ max_length=2048, unique=True, default=generate_client_id, db_index=True
+ )
+
# NOTE: By default an application should be linked to the organization that created it.
# It can be null if the organization that created it is deleted, or it was created outside of an organization (e.g. using dynamic client registration)
# Only admins of the organization should have permission to edit the application.
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 4496e530e403..60c06acc94dc 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -50259,7 +50259,7 @@ export namespace Schemas {
readonly id: string;
/** @maxLength 255 */
name?: string;
- /** @maxLength 100 */
+ /** @maxLength 2048 */
client_id?: string;
readonly redirect_uris_list: readonly string[];
/** True if this application has been verified by PostHog */