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(workflows): Drop UUID coercion now that person_id is TEXT (#59115)

Daniel Marchukaa6bac4db656
diff --git a/nodejs/src/cdp/services/cyclotron-v2/cyclotron-v2.test.ts b/nodejs/src/cdp/services/cyclotron-v2/cyclotron-v2.test.ts
index 5ae9489d8614..c3e26eb21c75 100644
--- a/nodejs/src/cdp/services/cyclotron-v2/cyclotron-v2.test.ts
+++ b/nodejs/src/cdp/services/cyclotron-v2/cyclotron-v2.test.ts
@@ -265,22 +265,22 @@ describe('Cyclotron V2', () => {
}
})
- it('createJob coerces non-UUID personId to null', async () => {
- const id = await manager.createJob({ teamId: 1, queueName: QUEUE, personId: 'not-a-uuid' as any })
+ it('createJob accepts a non-UUID personId (column is TEXT)', async () => {
+ const id = await manager.createJob({ teamId: 1, queueName: QUEUE, personId: 'group-key-not-a-uuid' })
const row = await queryJob(id)
- expect(row.person_id).toBeNull()
+ expect(row.person_id).toBe('group-key-not-a-uuid')
})
- it('bulkCreateJobs coerces non-UUID personIds to null instead of failing the batch', async () => {
+ it('bulkCreateJobs accepts mixed UUID and non-UUID personIds', async () => {
const validPersonId = uuidv7()
const ids = await manager.bulkCreateJobs([
{ teamId: 1, queueName: QUEUE, personId: validPersonId },
- { teamId: 1, queueName: QUEUE, personId: 'group-key-not-a-uuid' as any },
+ { teamId: 1, queueName: QUEUE, personId: 'group-key-not-a-uuid' },
])
expect(ids).toHaveLength(2)
const rows = await Promise.all(ids.map(queryJob))
expect(rows[0].person_id).toBe(validPersonId)
- expect(rows[1].person_id).toBeNull()
+ expect(rows[1].person_id).toBe('group-key-not-a-uuid')
})
})
@@ -423,12 +423,12 @@ describe('Cyclotron V2', () => {
expect(job.actionId).toBe('a-on-job')
})
- it('reschedule coerces non-UUID personId to null instead of failing', async () => {
+ it('reschedule accepts a non-UUID personId', async () => {
const { id, job } = await seedAndDequeue({ personId: uuidv7() })
- await job.reschedule({ personId: 'bad-uuid' as any })
+ await job.reschedule({ personId: 'group-key-not-a-uuid' })
const row = await queryJob(id)
- expect(row.person_id).toBeNull()
+ expect(row.person_id).toBe('group-key-not-a-uuid')
})
it('reschedule({ distinctId }) updates distinct_id column', async () => {
diff --git a/nodejs/src/cdp/services/cyclotron-v2/manager.ts b/nodejs/src/cdp/services/cyclotron-v2/manager.ts
index 31bccc1b8e27..994bed710239 100644
--- a/nodejs/src/cdp/services/cyclotron-v2/manager.ts
+++ b/nodejs/src/cdp/services/cyclotron-v2/manager.ts
@@ -1,33 +1,9 @@
import { Pool } from 'pg'
-import { v7 as uuidv7, validate as validateUuid } from 'uuid'
+import { v7 as uuidv7 } from 'uuid'
import { logger } from '../../../utils/logger'
import { CyclotronV2JobInit, CyclotronV2JobInitSchema, CyclotronV2ManagerConfig } from './types'
-// Diagnostic helper: surface non-UUID personId values arriving at the queue so we can trace
-// which producer is sending them. The schema silently coerces these to null; this log gives
-// us the value plus job context (team, function, queue) we need to root-cause the source.
-// The whole body is wrapped in try/catch so diagnostic logging can never break the job-create path.
-function logNonUuidPersonId(input: CyclotronV2JobInit): void {
- try {
- if (typeof input.personId !== 'string') {
- return
- }
- if (validateUuid(input.personId)) {
- return
- }
- logger.warn('Non-UUID personId on cyclotron-v2 job, will be coerced to null', {
- teamId: input.teamId,
- functionId: input.functionId ?? null,
- queueName: input.queueName,
- parentRunId: input.parentRunId ?? null,
- personId: input.personId,
- })
- } catch {
- // Diagnostic logging must never break the job-create path.
- }
-}
-
export class CyclotronV2Manager {
private pool: Pool
private readonly depthLimit: number
@@ -51,7 +27,6 @@ export class CyclotronV2Manager {
}
async createJob(input: CyclotronV2JobInit): Promise<string> {
- logNonUuidPersonId(input)
const job = CyclotronV2JobInitSchema.parse(input)
await this.insertGuard()
@@ -88,10 +63,6 @@ export class CyclotronV2Manager {
return []
}
- for (const input of inputs) {
- logNonUuidPersonId(input)
- }
-
const jobs = inputs.map((input) => CyclotronV2JobInitSchema.parse(input))
await this.insertGuard()
@@ -147,7 +118,7 @@ export class CyclotronV2Manager {
unnest($7::text[]),
unnest($8::bytea[]),
unnest($9::text[]),
- unnest($10::uuid[]),
+ unnest($10::text[]),
unnest($11::text[])`,
[
ids,
diff --git a/nodejs/src/cdp/services/cyclotron-v2/types.test.ts b/nodejs/src/cdp/services/cyclotron-v2/types.test.ts
index ad7d92ca1062..426b16c3d2c9 100644
--- a/nodejs/src/cdp/services/cyclotron-v2/types.test.ts
+++ b/nodejs/src/cdp/services/cyclotron-v2/types.test.ts
@@ -3,31 +3,22 @@ import { v7 as uuidv7 } from 'uuid'
import { CyclotronV2JobInitSchema, CyclotronV2RescheduleOptionsSchema } from './types'
describe('CyclotronV2 schema validation', () => {
- describe('personId coercion in CyclotronV2JobInitSchema', () => {
+ describe('personId in CyclotronV2JobInitSchema', () => {
it('accepts a valid UUID and preserves it', () => {
const personId = uuidv7()
const parsed = CyclotronV2JobInitSchema.parse({ teamId: 1, queueName: 'q', personId })
expect(parsed.personId).toBe(personId)
})
- it('coerces non-UUID strings to null (e.g. group keys from blast radius)', () => {
- const parsed = CyclotronV2JobInitSchema.parse({
- teamId: 1,
- queueName: 'q',
- personId: 'group-key-not-a-uuid',
- })
- expect(parsed.personId).toBeNull()
- })
-
it.each([
+ ['arbitrary text', 'group-key-not-a-uuid'],
['empty string', ''],
- ['arbitrary text', 'not-a-uuid'],
['nearly-uuid', '12345678-1234-1234-1234-12345678901'],
['numeric id', '12345'],
['email-like', '[email protected]'],
- ])('coerces %s to null', (_, value) => {
+ ])('passes %s through unchanged', (_, value) => {
const parsed = CyclotronV2JobInitSchema.parse({ teamId: 1, queueName: 'q', personId: value })
- expect(parsed.personId).toBeNull()
+ expect(parsed.personId).toBe(value)
})
it('passes through null', () => {
@@ -47,16 +38,16 @@ describe('CyclotronV2 schema validation', () => {
})
})
- describe('personId coercion in CyclotronV2RescheduleOptionsSchema', () => {
+ describe('personId in CyclotronV2RescheduleOptionsSchema', () => {
it('accepts a valid UUID', () => {
const personId = uuidv7()
const parsed = CyclotronV2RescheduleOptionsSchema.parse({ personId })
expect(parsed.personId).toBe(personId)
})
- it('coerces non-UUID strings to null', () => {
+ it('passes a non-UUID string through unchanged', () => {
const parsed = CyclotronV2RescheduleOptionsSchema.parse({ personId: 'group-key' })
- expect(parsed.personId).toBeNull()
+ expect(parsed.personId).toBe('group-key')
})
it('passes through null', () => {
diff --git a/nodejs/src/cdp/services/cyclotron-v2/types.ts b/nodejs/src/cdp/services/cyclotron-v2/types.ts
index 5b86fd10419a..10e5f92fcd71 100644
--- a/nodejs/src/cdp/services/cyclotron-v2/types.ts
+++ b/nodejs/src/cdp/services/cyclotron-v2/types.ts
@@ -9,19 +9,6 @@ export type CyclotronV2PoolConfig = {
idleTimeoutMs?: number
}
-// `id` and `functionId` use PostHog's UUIDT-style identifiers which don't set
-// valid UUID version bits, so we only validate them as non-empty strings here.
-// `personId` comes from posthog_person.uuid (a real UUID v4/v7) for person-based
-// blast radius, but group-based blast radius returns group keys (non-UUID strings).
-// We coerce non-UUID values to null so the postgres UUID column accepts them
-// rather than failing the whole batch insert.
-const personIdSchema = z.preprocess((val) => {
- if (typeof val === 'string' && !z.uuid().safeParse(val).success) {
- return null
- }
- return val
-}, z.uuid().nullish())
-
export const CyclotronV2JobInitSchema = z.object({
id: z.string().min(1).optional(),
teamId: z.number().int(),
@@ -32,7 +19,7 @@ export const CyclotronV2JobInitSchema = z.object({
parentRunId: z.string().nullish(),
state: z.instanceof(Buffer).nullish(),
distinctId: z.string().nullish(),
- personId: personIdSchema,
+ personId: z.string().nullish(),
actionId: z.string().nullish(),
})
@@ -42,7 +29,7 @@ export const CyclotronV2RescheduleOptionsSchema = z.object({
scheduledAt: z.date().optional(),
state: z.instanceof(Buffer).nullish(),
distinctId: z.string().nullish(),
- personId: personIdSchema,
+ personId: z.string().nullish(),
actionId: z.string().nullish(),
})