From f08cde0cd8ce837071c9ce0b55da065d205181e8 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Tue, 5 May 2026 14:20:23 -0700 Subject: [PATCH] fix(posthog): align tool params with subBlock canonical to fix missing-field error Tool params were named `personalApiKey` but the subBlock resolves to canonical `apiKey`, so canonical-group resolution wrote the value to params.apiKey while the validator looked up params.personalApiKey and reported it missing. Renames `personalApiKey` -> `apiKey` in get_person, query, list_persons, delete_person, and types.ts. Also tightens check-block-registry.ts so a subBlock with canonicalParamId no longer satisfies a tool param lookup by its raw id (the raw id is deleted during extraction). --- apps/sim/scripts/check-block-registry.ts | 11 +++++++++-- apps/sim/tools/posthog/delete_person.ts | 6 +++--- apps/sim/tools/posthog/get_person.ts | 6 +++--- apps/sim/tools/posthog/list_persons.ts | 6 +++--- apps/sim/tools/posthog/query.ts | 6 +++--- apps/sim/tools/posthog/types.ts | 2 +- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/apps/sim/scripts/check-block-registry.ts b/apps/sim/scripts/check-block-registry.ts index 370f822b1f8..864c964f33d 100644 --- a/apps/sim/scripts/check-block-registry.ts +++ b/apps/sim/scripts/check-block-registry.ts @@ -196,11 +196,18 @@ function checkCanonicalIdContract(): CheckResult { const access: string[] = block.tools?.access ?? [] if (access.length === 0) continue + // A subBlock with `canonicalParamId` has its raw `id` deleted from `params` during + // canonical-group resolution in `extractParams` (serializer/index.ts), so the raw id is + // NOT a valid lookup key at execution time — only the canonical is. Tool params must + // align with the canonical, not the raw id. const subBlockKeys = new Set() for (const sb of block.subBlocks ?? []) { - if (sb.id) subBlockKeys.add(sb.id) const canonical = (sb as { canonicalParamId?: string }).canonicalParamId - if (canonical) subBlockKeys.add(canonical) + if (canonical) { + subBlockKeys.add(canonical) + } else if (sb.id) { + subBlockKeys.add(sb.id) + } } for (const toolId of access) { diff --git a/apps/sim/tools/posthog/delete_person.ts b/apps/sim/tools/posthog/delete_person.ts index 8782c4d9cd3..ccfce302282 100644 --- a/apps/sim/tools/posthog/delete_person.ts +++ b/apps/sim/tools/posthog/delete_person.ts @@ -1,7 +1,7 @@ import type { ToolConfig } from '@/tools/types' export interface PostHogDeletePersonParams { - personalApiKey: string + apiKey: string region?: 'us' | 'eu' projectId: string personId: string @@ -23,7 +23,7 @@ export const deletePersonTool: ToolConfig ({ - Authorization: `Bearer ${params.personalApiKey}`, + Authorization: `Bearer ${params.apiKey}`, 'Content-Type': 'application/json', }), }, diff --git a/apps/sim/tools/posthog/get_person.ts b/apps/sim/tools/posthog/get_person.ts index 6b59854b46f..ca3b53be7cf 100644 --- a/apps/sim/tools/posthog/get_person.ts +++ b/apps/sim/tools/posthog/get_person.ts @@ -1,7 +1,7 @@ import type { ToolConfig } from '@/tools/types' export interface PostHogGetPersonParams { - personalApiKey: string + apiKey: string region?: 'us' | 'eu' projectId: string personId: string @@ -28,7 +28,7 @@ export const getPersonTool: ToolConfig ({ - Authorization: `Bearer ${params.personalApiKey}`, + Authorization: `Bearer ${params.apiKey}`, 'Content-Type': 'application/json', }), }, diff --git a/apps/sim/tools/posthog/list_persons.ts b/apps/sim/tools/posthog/list_persons.ts index 2857c5b7e60..5271afd2883 100644 --- a/apps/sim/tools/posthog/list_persons.ts +++ b/apps/sim/tools/posthog/list_persons.ts @@ -1,7 +1,7 @@ import type { ToolConfig } from '@/tools/types' export interface PostHogListPersonsParams { - personalApiKey: string + apiKey: string region?: 'us' | 'eu' projectId: string limit?: number @@ -35,7 +35,7 @@ export const listPersonsTool: ToolConfig ({ - Authorization: `Bearer ${params.personalApiKey}`, + Authorization: `Bearer ${params.apiKey}`, 'Content-Type': 'application/json', }), }, diff --git a/apps/sim/tools/posthog/query.ts b/apps/sim/tools/posthog/query.ts index 4cbb0692cbc..050dd81f14e 100644 --- a/apps/sim/tools/posthog/query.ts +++ b/apps/sim/tools/posthog/query.ts @@ -1,7 +1,7 @@ import type { ToolConfig } from '@/tools/types' export interface PostHogQueryParams { - personalApiKey: string + apiKey: string region?: 'us' | 'eu' projectId: string query: string @@ -27,7 +27,7 @@ export const queryTool: ToolConfig = { version: '1.0.0', params: { - personalApiKey: { + apiKey: { type: 'string', required: true, visibility: 'user-only', @@ -69,7 +69,7 @@ export const queryTool: ToolConfig = { }, method: 'POST', headers: (params) => ({ - Authorization: `Bearer ${params.personalApiKey}`, + Authorization: `Bearer ${params.apiKey}`, 'Content-Type': 'application/json', }), body: (params) => { diff --git a/apps/sim/tools/posthog/types.ts b/apps/sim/tools/posthog/types.ts index 2a258dfc039..39a78cf1377 100644 --- a/apps/sim/tools/posthog/types.ts +++ b/apps/sim/tools/posthog/types.ts @@ -11,7 +11,7 @@ export interface PostHogPublicParams extends PostHogBaseParams { } export interface PostHogPrivateParams extends PostHogBaseParams { - personalApiKey: string + apiKey: string projectId: string }