Skip to content

Commit b69c906

Browse files
committed
fix(wordpress): fix search type/subtype mislabeling, complete I/O exposure gaps
- search_content.ts: type param was mislabeled with subtype's vocabulary (post/page/attachment); real WP type enum is post/term/post-format. Rewired the block's Content Type dropdown to map to subtype (which is what post/page/attachment actually filter), not type. - Widened subBlock conditions so params already read by tools.config.params are actually reachable in the UI: commentPostId for list_comments, categories/tags for list_posts, parent for list_pages. - Added missing subBlocks for tool params with no UI path: comment parent/authorName/authorEmail/authorUrl (create_comment), media description (upload_media), author filter (list_posts). - Extended the ?? / !== undefined fix (already applied to categoryParent) to the same class of param across the block: featuredMedia, page parent, menuOrder, and the new commentParent/listAuthor mappings. - Fixed featuredMedia/parent truthy-check inconsistency in create_post, update_post, create_page, update_page, create_category, create_comment body builders to match the !== undefined convention used elsewhere. Found by an independent final validation pass across 3 parallel agents.
1 parent 3e54a46 commit b69c906

9 files changed

Lines changed: 136 additions & 31 deletions

File tree

apps/sim/blocks/blocks/wordpress.ts

Lines changed: 119 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
214214
},
215215
},
216216

217-
// Categories (for posts only)
217+
// Categories (for posts)
218218
{
219219
id: 'categories',
220220
title: 'Categories',
@@ -223,11 +223,11 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
223223
mode: 'advanced',
224224
condition: {
225225
field: 'operation',
226-
value: ['wordpress_create_post', 'wordpress_update_post'],
226+
value: ['wordpress_create_post', 'wordpress_update_post', 'wordpress_list_posts'],
227227
},
228228
},
229229

230-
// Tags (for posts only)
230+
// Tags (for posts)
231231
{
232232
id: 'tags',
233233
title: 'Tags',
@@ -236,10 +236,20 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
236236
mode: 'advanced',
237237
condition: {
238238
field: 'operation',
239-
value: ['wordpress_create_post', 'wordpress_update_post'],
239+
value: ['wordpress_create_post', 'wordpress_update_post', 'wordpress_list_posts'],
240240
},
241241
},
242242

243+
// List Posts: Author filter
244+
{
245+
id: 'listAuthor',
246+
title: 'Author ID',
247+
type: 'short-input',
248+
placeholder: 'Filter by author ID',
249+
mode: 'advanced',
250+
condition: { field: 'operation', value: 'wordpress_list_posts' },
251+
},
252+
243253
// Featured Media ID
244254
{
245255
id: 'featuredMedia',
@@ -283,7 +293,7 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
283293
mode: 'advanced',
284294
condition: {
285295
field: 'operation',
286-
value: ['wordpress_create_page', 'wordpress_update_page'],
296+
value: ['wordpress_create_page', 'wordpress_update_page', 'wordpress_list_pages'],
287297
},
288298
},
289299

@@ -355,6 +365,14 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
355365
mode: 'advanced',
356366
condition: { field: 'operation', value: 'wordpress_upload_media' },
357367
},
368+
{
369+
id: 'mediaDescription',
370+
title: 'Description',
371+
type: 'long-input',
372+
placeholder: 'Media description',
373+
mode: 'advanced',
374+
condition: { field: 'operation', value: 'wordpress_upload_media' },
375+
},
358376
{
359377
id: 'mediaId',
360378
title: 'Media ID',
@@ -391,7 +409,10 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
391409
title: 'Post ID',
392410
type: 'short-input',
393411
placeholder: 'Post ID to comment on',
394-
condition: { field: 'operation', value: 'wordpress_create_comment' },
412+
condition: {
413+
field: 'operation',
414+
value: ['wordpress_create_comment', 'wordpress_list_comments'],
415+
},
395416
required: { field: 'operation', value: 'wordpress_create_comment' },
396417
},
397418
{
@@ -405,6 +426,38 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
405426
},
406427
required: { field: 'operation', value: 'wordpress_create_comment' },
407428
},
429+
{
430+
id: 'commentParent',
431+
title: 'Parent Comment ID',
432+
type: 'short-input',
433+
placeholder: 'Parent comment ID (for replies)',
434+
mode: 'advanced',
435+
condition: { field: 'operation', value: 'wordpress_create_comment' },
436+
},
437+
{
438+
id: 'commentAuthorName',
439+
title: 'Author Name',
440+
type: 'short-input',
441+
placeholder: 'Comment author display name',
442+
mode: 'advanced',
443+
condition: { field: 'operation', value: 'wordpress_create_comment' },
444+
},
445+
{
446+
id: 'commentAuthorEmail',
447+
title: 'Author Email',
448+
type: 'short-input',
449+
placeholder: 'Comment author email',
450+
mode: 'advanced',
451+
condition: { field: 'operation', value: 'wordpress_create_comment' },
452+
},
453+
{
454+
id: 'commentAuthorUrl',
455+
title: 'Author URL',
456+
type: 'short-input',
457+
placeholder: 'Comment author URL',
458+
mode: 'advanced',
459+
condition: { field: 'operation', value: 'wordpress_create_comment' },
460+
},
408461
{
409462
id: 'commentId',
410463
title: 'Comment ID',
@@ -571,7 +624,7 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
571624
required: { field: 'operation', value: 'wordpress_search_content' },
572625
},
573626
{
574-
id: 'searchType',
627+
id: 'searchSubtype',
575628
title: 'Content Type',
576629
type: 'dropdown',
577630
options: [
@@ -779,7 +832,10 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
779832
slug: params.slug,
780833
categories: params.categories,
781834
tags: params.tags,
782-
featuredMedia: params.featuredMedia ? Number(params.featuredMedia) : undefined,
835+
featuredMedia:
836+
params.featuredMedia !== undefined && params.featuredMedia !== ''
837+
? Number(params.featuredMedia)
838+
: undefined,
783839
}
784840
case 'wordpress_update_post':
785841
return {
@@ -792,7 +848,10 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
792848
slug: params.slug,
793849
categories: params.categories,
794850
tags: params.tags,
795-
featuredMedia: params.featuredMedia ? Number(params.featuredMedia) : undefined,
851+
featuredMedia:
852+
params.featuredMedia !== undefined && params.featuredMedia !== ''
853+
? Number(params.featuredMedia)
854+
: undefined,
796855
}
797856
case 'wordpress_delete_post':
798857
return {
@@ -816,6 +875,10 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
816875
order: params.order,
817876
categories: params.categories,
818877
tags: params.tags,
878+
author:
879+
params.listAuthor !== undefined && params.listAuthor !== ''
880+
? Number(params.listAuthor)
881+
: undefined,
819882
}
820883
case 'wordpress_create_page':
821884
return {
@@ -825,9 +888,18 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
825888
status: params.status,
826889
excerpt: params.excerpt,
827890
slug: params.slug,
828-
parent: params.parent ? Number(params.parent) : undefined,
829-
menuOrder: params.menuOrder ? Number(params.menuOrder) : undefined,
830-
featuredMedia: params.featuredMedia ? Number(params.featuredMedia) : undefined,
891+
parent:
892+
params.parent !== undefined && params.parent !== ''
893+
? Number(params.parent)
894+
: undefined,
895+
menuOrder:
896+
params.menuOrder !== undefined && params.menuOrder !== ''
897+
? Number(params.menuOrder)
898+
: undefined,
899+
featuredMedia:
900+
params.featuredMedia !== undefined && params.featuredMedia !== ''
901+
? Number(params.featuredMedia)
902+
: undefined,
831903
}
832904
case 'wordpress_update_page':
833905
return {
@@ -838,9 +910,18 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
838910
status: params.status,
839911
excerpt: params.excerpt,
840912
slug: params.slug,
841-
parent: params.parent ? Number(params.parent) : undefined,
842-
menuOrder: params.menuOrder ? Number(params.menuOrder) : undefined,
843-
featuredMedia: params.featuredMedia ? Number(params.featuredMedia) : undefined,
913+
parent:
914+
params.parent !== undefined && params.parent !== ''
915+
? Number(params.parent)
916+
: undefined,
917+
menuOrder:
918+
params.menuOrder !== undefined && params.menuOrder !== ''
919+
? Number(params.menuOrder)
920+
: undefined,
921+
featuredMedia:
922+
params.featuredMedia !== undefined && params.featuredMedia !== ''
923+
? Number(params.featuredMedia)
924+
: undefined,
844925
}
845926
case 'wordpress_delete_page':
846927
return {
@@ -862,7 +943,10 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
862943
search: params.search,
863944
orderBy: params.orderBy,
864945
order: params.order,
865-
parent: params.parent ? Number(params.parent) : undefined,
946+
parent:
947+
params.parent !== undefined && params.parent !== ''
948+
? Number(params.parent)
949+
: undefined,
866950
}
867951
case 'wordpress_upload_media':
868952
// file is the canonical param for both basic (fileUpload) and advanced modes
@@ -873,6 +957,7 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
873957
title: params.mediaTitle,
874958
caption: params.caption,
875959
altText: params.altText,
960+
description: params.mediaDescription || undefined,
876961
}
877962
case 'wordpress_get_media':
878963
return {
@@ -899,6 +984,13 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
899984
...baseParams,
900985
postId: Number(params.commentPostId),
901986
content: params.commentContent,
987+
parent:
988+
params.commentParent !== undefined && params.commentParent !== ''
989+
? Number(params.commentParent)
990+
: undefined,
991+
authorName: params.commentAuthorName || undefined,
992+
authorEmail: params.commentAuthorEmail || undefined,
993+
authorUrl: params.commentAuthorUrl || undefined,
902994
}
903995
case 'wordpress_list_comments':
904996
return {
@@ -1019,7 +1111,7 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
10191111
query: params.query,
10201112
perPage: params.perPage ? Number(params.perPage) : undefined,
10211113
page: params.page ? Number(params.page) : undefined,
1022-
type: params.searchType || undefined,
1114+
subtype: params.searchSubtype || undefined,
10231115
}
10241116
default:
10251117
return baseParams
@@ -1040,6 +1132,7 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
10401132
slug: { type: 'string', description: 'URL slug' },
10411133
categories: { type: 'string', description: 'Category IDs (comma-separated)' },
10421134
tags: { type: 'string', description: 'Tag IDs (comma-separated)' },
1135+
listAuthor: { type: 'string', description: 'Filter posts by author ID' },
10431136
featuredMedia: { type: 'number', description: 'Featured media ID' },
10441137
// Page inputs
10451138
pageId: { type: 'number', description: 'Page ID' },
@@ -1051,11 +1144,16 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
10511144
mediaTitle: { type: 'string', description: 'Media title' },
10521145
caption: { type: 'string', description: 'Media caption' },
10531146
altText: { type: 'string', description: 'Alt text' },
1147+
mediaDescription: { type: 'string', description: 'Media description' },
10541148
mediaId: { type: 'number', description: 'Media ID' },
10551149
mediaType: { type: 'string', description: 'Media type filter' },
10561150
// Comment inputs
10571151
commentPostId: { type: 'number', description: 'Post ID for comment' },
10581152
commentContent: { type: 'string', description: 'Comment content' },
1153+
commentParent: { type: 'number', description: 'Parent comment ID for replies' },
1154+
commentAuthorName: { type: 'string', description: 'Comment author display name' },
1155+
commentAuthorEmail: { type: 'string', description: 'Comment author email' },
1156+
commentAuthorUrl: { type: 'string', description: 'Comment author URL' },
10591157
commentId: { type: 'number', description: 'Comment ID' },
10601158
commentStatus: { type: 'string', description: 'Comment status' },
10611159
// Category inputs
@@ -1074,7 +1172,10 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
10741172
roles: { type: 'string', description: 'User roles filter' },
10751173
// Search inputs
10761174
query: { type: 'string', description: 'Search query' },
1077-
searchType: { type: 'string', description: 'Content type filter' },
1175+
searchSubtype: {
1176+
type: 'string',
1177+
description: 'Content subtype filter (post, page, attachment)',
1178+
},
10781179
// List inputs
10791180
perPage: { type: 'number', description: 'Results per page' },
10801181
page: { type: 'number', description: 'Page number' },

apps/sim/tools/wordpress/create_category.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const createCategoryTool: ToolConfig<
6666
}
6767

6868
if (params.description) body.description = params.description
69-
if (params.parent) body.parent = params.parent
69+
if (params.parent !== undefined) body.parent = params.parent
7070
if (params.slug) body.slug = params.slug
7171

7272
return body

apps/sim/tools/wordpress/create_comment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const createCommentTool: ToolConfig<
7878
content: params.content,
7979
}
8080

81-
if (params.parent) body.parent = params.parent
81+
if (params.parent !== undefined) body.parent = params.parent
8282
if (params.authorName) body.author_name = params.authorName
8383
if (params.authorEmail) body.author_email = params.authorEmail
8484
if (params.authorUrl) body.author_url = params.authorUrl

apps/sim/tools/wordpress/create_page.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ export const createPageTool: ToolConfig<WordPressCreatePageParams, WordPressCrea
9090
if (params.status) body.status = params.status
9191
if (params.excerpt) body.excerpt = params.excerpt
9292
if (params.slug) body.slug = params.slug
93-
if (params.parent) body.parent = params.parent
94-
if (params.menuOrder) body.menu_order = params.menuOrder
95-
if (params.featuredMedia) body.featured_media = params.featuredMedia
93+
if (params.parent !== undefined) body.parent = params.parent
94+
if (params.menuOrder !== undefined) body.menu_order = params.menuOrder
95+
if (params.featuredMedia !== undefined) body.featured_media = params.featuredMedia
9696

9797
return body
9898
},

apps/sim/tools/wordpress/create_post.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const createPostTool: ToolConfig<WordPressCreatePostParams, WordPressCrea
9090
if (params.status) body.status = params.status
9191
if (params.excerpt) body.excerpt = params.excerpt
9292
if (params.slug) body.slug = params.slug
93-
if (params.featuredMedia) body.featured_media = params.featuredMedia
93+
if (params.featuredMedia !== undefined) body.featured_media = params.featuredMedia
9494

9595
if (params.categories) {
9696
body.categories = params.categories

apps/sim/tools/wordpress/search_content.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ export const searchContentTool: ToolConfig<
4949
type: 'string',
5050
required: false,
5151
visibility: 'user-only',
52-
description: 'Filter by content type: post, page, attachment',
52+
description: 'Filter by search index type: post, term, or post-format',
5353
},
5454
subtype: {
5555
type: 'string',
5656
required: false,
5757
visibility: 'user-only',
58-
description: 'Filter by post type slug (e.g., post, page)',
58+
description:
59+
'Filter by subtype within the selected type (e.g., post or page when type is post)',
5960
},
6061
},
6162

@@ -114,8 +115,11 @@ export const searchContentTool: ToolConfig<
114115
id: { type: 'number', description: 'Content ID' },
115116
title: { type: 'string', description: 'Content title' },
116117
url: { type: 'string', description: 'Content URL' },
117-
type: { type: 'string', description: 'Content type (post, page, attachment)' },
118-
subtype: { type: 'string', description: 'Post type slug' },
118+
type: { type: 'string', description: 'Content type (post, term, or post-format)' },
119+
subtype: {
120+
type: 'string',
121+
description: 'Subtype within the content type (e.g., post, page)',
122+
},
119123
},
120124
},
121125
},

apps/sim/tools/wordpress/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ export interface WordPressSearchContentParams extends WordPressBaseParams {
650650
query: string
651651
perPage?: number
652652
page?: number
653-
type?: 'post' | 'page' | 'attachment'
653+
type?: 'post' | 'term' | 'post-format'
654654
subtype?: string
655655
}
656656

apps/sim/tools/wordpress/update_page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const updatePageTool: ToolConfig<WordPressUpdatePageParams, WordPressUpda
9797
if (params.slug) body.slug = params.slug
9898
if (params.parent !== undefined) body.parent = params.parent
9999
if (params.menuOrder !== undefined) body.menu_order = params.menuOrder
100-
if (params.featuredMedia) body.featured_media = params.featuredMedia
100+
if (params.featuredMedia !== undefined) body.featured_media = params.featuredMedia
101101

102102
return body
103103
},

apps/sim/tools/wordpress/update_post.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export const updatePostTool: ToolConfig<WordPressUpdatePostParams, WordPressUpda
9595
if (params.status) body.status = params.status
9696
if (params.excerpt) body.excerpt = params.excerpt
9797
if (params.slug) body.slug = params.slug
98-
if (params.featuredMedia) body.featured_media = params.featuredMedia
98+
if (params.featuredMedia !== undefined) body.featured_media = params.featuredMedia
9999

100100
if (params.categories) {
101101
body.categories = params.categories

0 commit comments

Comments
 (0)