Skip to content

Commit 1baa580

Browse files
authored
fix(posthog): align tool params with subBlock canonical to fix missing-field error (#4455)
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).
1 parent 0337ccd commit 1baa580

6 files changed

Lines changed: 22 additions & 15 deletions

File tree

apps/sim/scripts/check-block-registry.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,18 @@ function checkCanonicalIdContract(): CheckResult {
196196
const access: string[] = block.tools?.access ?? []
197197
if (access.length === 0) continue
198198

199+
// A subBlock with `canonicalParamId` has its raw `id` deleted from `params` during
200+
// canonical-group resolution in `extractParams` (serializer/index.ts), so the raw id is
201+
// NOT a valid lookup key at execution time — only the canonical is. Tool params must
202+
// align with the canonical, not the raw id.
199203
const subBlockKeys = new Set<string>()
200204
for (const sb of block.subBlocks ?? []) {
201-
if (sb.id) subBlockKeys.add(sb.id)
202205
const canonical = (sb as { canonicalParamId?: string }).canonicalParamId
203-
if (canonical) subBlockKeys.add(canonical)
206+
if (canonical) {
207+
subBlockKeys.add(canonical)
208+
} else if (sb.id) {
209+
subBlockKeys.add(sb.id)
210+
}
204211
}
205212

206213
for (const toolId of access) {

apps/sim/tools/posthog/delete_person.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ToolConfig } from '@/tools/types'
22

33
export interface PostHogDeletePersonParams {
4-
personalApiKey: string
4+
apiKey: string
55
region?: 'us' | 'eu'
66
projectId: string
77
personId: string
@@ -23,7 +23,7 @@ export const deletePersonTool: ToolConfig<PostHogDeletePersonParams, PostHogDele
2323
version: '1.0.0',
2424

2525
params: {
26-
personalApiKey: {
26+
apiKey: {
2727
type: 'string',
2828
required: true,
2929
visibility: 'user-only',
@@ -57,7 +57,7 @@ export const deletePersonTool: ToolConfig<PostHogDeletePersonParams, PostHogDele
5757
},
5858
method: 'DELETE',
5959
headers: (params) => ({
60-
Authorization: `Bearer ${params.personalApiKey}`,
60+
Authorization: `Bearer ${params.apiKey}`,
6161
'Content-Type': 'application/json',
6262
}),
6363
},

apps/sim/tools/posthog/get_person.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ToolConfig } from '@/tools/types'
22

33
export interface PostHogGetPersonParams {
4-
personalApiKey: string
4+
apiKey: string
55
region?: 'us' | 'eu'
66
projectId: string
77
personId: string
@@ -28,7 +28,7 @@ export const getPersonTool: ToolConfig<PostHogGetPersonParams, PostHogGetPersonR
2828
version: '1.0.0',
2929

3030
params: {
31-
personalApiKey: {
31+
apiKey: {
3232
type: 'string',
3333
required: true,
3434
visibility: 'user-only',
@@ -62,7 +62,7 @@ export const getPersonTool: ToolConfig<PostHogGetPersonParams, PostHogGetPersonR
6262
},
6363
method: 'GET',
6464
headers: (params) => ({
65-
Authorization: `Bearer ${params.personalApiKey}`,
65+
Authorization: `Bearer ${params.apiKey}`,
6666
'Content-Type': 'application/json',
6767
}),
6868
},

apps/sim/tools/posthog/list_persons.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ToolConfig } from '@/tools/types'
22

33
export interface PostHogListPersonsParams {
4-
personalApiKey: string
4+
apiKey: string
55
region?: 'us' | 'eu'
66
projectId: string
77
limit?: number
@@ -35,7 +35,7 @@ export const listPersonsTool: ToolConfig<PostHogListPersonsParams, PostHogListPe
3535
version: '1.0.0',
3636

3737
params: {
38-
personalApiKey: {
38+
apiKey: {
3939
type: 'string',
4040
required: true,
4141
visibility: 'user-only',
@@ -95,7 +95,7 @@ export const listPersonsTool: ToolConfig<PostHogListPersonsParams, PostHogListPe
9595
},
9696
method: 'GET',
9797
headers: (params) => ({
98-
Authorization: `Bearer ${params.personalApiKey}`,
98+
Authorization: `Bearer ${params.apiKey}`,
9999
'Content-Type': 'application/json',
100100
}),
101101
},

apps/sim/tools/posthog/query.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ToolConfig } from '@/tools/types'
22

33
export interface PostHogQueryParams {
4-
personalApiKey: string
4+
apiKey: string
55
region?: 'us' | 'eu'
66
projectId: string
77
query: string
@@ -27,7 +27,7 @@ export const queryTool: ToolConfig<PostHogQueryParams, PostHogQueryResponse> = {
2727
version: '1.0.0',
2828

2929
params: {
30-
personalApiKey: {
30+
apiKey: {
3131
type: 'string',
3232
required: true,
3333
visibility: 'user-only',
@@ -69,7 +69,7 @@ export const queryTool: ToolConfig<PostHogQueryParams, PostHogQueryResponse> = {
6969
},
7070
method: 'POST',
7171
headers: (params) => ({
72-
Authorization: `Bearer ${params.personalApiKey}`,
72+
Authorization: `Bearer ${params.apiKey}`,
7373
'Content-Type': 'application/json',
7474
}),
7575
body: (params) => {

apps/sim/tools/posthog/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface PostHogPublicParams extends PostHogBaseParams {
1111
}
1212

1313
export interface PostHogPrivateParams extends PostHogBaseParams {
14-
personalApiKey: string
14+
apiKey: string
1515
projectId: string
1616
}
1717

0 commit comments

Comments
 (0)