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).
This commit is contained in:
Waleed
2026-05-05 16:08:31 -07:00
committed by GitHub
parent 0337ccd7f3
commit 1baa58085a
6 changed files with 22 additions and 15 deletions
+9 -2
View File
@@ -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<string>()
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) {
+3 -3
View File
@@ -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<PostHogDeletePersonParams, PostHogDele
version: '1.0.0',
params: {
personalApiKey: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
@@ -57,7 +57,7 @@ export const deletePersonTool: ToolConfig<PostHogDeletePersonParams, PostHogDele
},
method: 'DELETE',
headers: (params) => ({
Authorization: `Bearer ${params.personalApiKey}`,
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
+3 -3
View File
@@ -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<PostHogGetPersonParams, PostHogGetPersonR
version: '1.0.0',
params: {
personalApiKey: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
@@ -62,7 +62,7 @@ export const getPersonTool: ToolConfig<PostHogGetPersonParams, PostHogGetPersonR
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.personalApiKey}`,
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
+3 -3
View File
@@ -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<PostHogListPersonsParams, PostHogListPe
version: '1.0.0',
params: {
personalApiKey: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
@@ -95,7 +95,7 @@ export const listPersonsTool: ToolConfig<PostHogListPersonsParams, PostHogListPe
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.personalApiKey}`,
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
+3 -3
View File
@@ -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<PostHogQueryParams, PostHogQueryResponse> = {
version: '1.0.0',
params: {
personalApiKey: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
@@ -69,7 +69,7 @@ export const queryTool: ToolConfig<PostHogQueryParams, PostHogQueryResponse> = {
},
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.personalApiKey}`,
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
+1 -1
View File
@@ -11,7 +11,7 @@ export interface PostHogPublicParams extends PostHogBaseParams {
}
export interface PostHogPrivateParams extends PostHogBaseParams {
personalApiKey: string
apiKey: string
projectId: string
}