Skip to content

Commit 4298418

Browse files
committed
fix(github,google_contacts): stop rejecting workflow file names, honor pageSize 0
GitHub documents workflow_id as 'the ID of the workflow. You can also pass the workflow file name as a string', and list_workflows prints that exact path to the model -- which the next call then threw on. Verified live: .github%2Fworkflows%2Fci.yml returns 200. Dropped the String() wrappers on 35 guarded ids; they defeated the guard's null rejection, so a missing id requested a resource named 'undefined'. People API documents pageSize 0 as 'use the default' (100 for list, 10 for search); the clamp rewrote it to 1, returning a single contact. The test pinned that behavior and is corrected.
1 parent 2ad892d commit 4298418

38 files changed

Lines changed: 302 additions & 67 deletions

apps/sim/blocks/blocks/google_contacts.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ import type { GoogleContactsResponse } from '@/tools/google_contacts/types'
1111
* to 30 (default 10). One shared subBlock feeds both, so the value is clamped
1212
* to the ceiling of whichever operation is selected rather than sending a
1313
* number the target operation would quietly reduce.
14+
*
15+
* `0` is not clamped, it is dropped. Both discovery descriptions give it a
16+
* meaning of its own — list: "Defaults to 100 if not set or set to 0";
17+
* search: "Defaults to 10 if field is not set, or set to 0" — so clamping it
18+
* up to the minimum of `1` turned a request for the default page into a
19+
* request for a single contact. Omitting the field reproduces "not set", which
20+
* is the same default Google documents for `0`.
1421
* @see https://developers.google.com/people/api/rest/v1/people.connections/list
1522
* @see https://developers.google.com/people/api/rest/v1/people/searchContacts
1623
*/
@@ -271,9 +278,10 @@ export const GoogleContactsBlock: BlockConfig<GoogleContactsResponse> = {
271278
const pageSizeMax = PAGE_SIZE_MAX_BY_OPERATION[operation]
272279
if (pageSizeMax !== undefined && processedParams.pageSize !== undefined) {
273280
const parsed = Number.parseInt(String(processedParams.pageSize), 10)
274-
processedParams.pageSize = Number.isNaN(parsed)
275-
? undefined
276-
: Math.min(Math.max(parsed, 1), pageSizeMax)
281+
processedParams.pageSize =
282+
Number.isNaN(parsed) || parsed === 0
283+
? undefined
284+
: Math.min(Math.max(parsed, 1), pageSizeMax)
277285
}
278286

279287
return {

apps/sim/tools/github/add_assignees.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const addAssigneesTool: ToolConfig<AddAssigneesParams, IssueResponse> = {
4343

4444
request: {
4545
url: (params) =>
46-
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/issues/${safeUrlPathSegment(String(params.issue_number), 'issue_number')}/assignees`,
46+
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/issues/${safeUrlPathSegment(params.issue_number, 'issue_number')}/assignees`,
4747
method: 'POST',
4848
headers: (params) => ({
4949
Accept: 'application/vnd.github.v3+json',

apps/sim/tools/github/add_labels.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const addLabelsTool: ToolConfig<AddLabelsParams, LabelsResponse> = {
4343

4444
request: {
4545
url: (params) =>
46-
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/issues/${safeUrlPathSegment(String(params.issue_number), 'issue_number')}/labels`,
46+
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/issues/${safeUrlPathSegment(params.issue_number, 'issue_number')}/labels`,
4747
method: 'POST',
4848
headers: (params) => ({
4949
Accept: 'application/vnd.github.v3+json',

apps/sim/tools/github/cancel_workflow_run.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const cancelWorkflowRunTool: ToolConfig<CancelWorkflowRunParams, CancelWo
3939

4040
request: {
4141
url: (params) =>
42-
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/actions/runs/${safeUrlPathSegment(String(params.run_id), 'run_id')}/cancel`,
42+
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/actions/runs/${safeUrlPathSegment(params.run_id, 'run_id')}/cancel`,
4343
method: 'POST',
4444
headers: (params) => ({
4545
Accept: 'application/vnd.github+json',

apps/sim/tools/github/close_issue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const closeIssueTool: ToolConfig<CloseIssueParams, IssueResponse> = {
4444

4545
request: {
4646
url: (params) =>
47-
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/issues/${safeUrlPathSegment(String(params.issue_number), 'issue_number')}`,
47+
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/issues/${safeUrlPathSegment(params.issue_number, 'issue_number')}`,
4848
method: 'PATCH',
4949
headers: (params) => ({
5050
Accept: 'application/vnd.github.v3+json',

apps/sim/tools/github/close_pr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const closePRTool: ToolConfig<ClosePRParams, PRResponse> = {
3737

3838
request: {
3939
url: (params) =>
40-
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/pulls/${safeUrlPathSegment(String(params.pullNumber), 'pullNumber')}`,
40+
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/pulls/${safeUrlPathSegment(params.pullNumber, 'pullNumber')}`,
4141
method: 'PATCH',
4242
headers: (params) => ({
4343
Accept: 'application/vnd.github.v3+json',

apps/sim/tools/github/comment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ export const commentTool: ToolConfig<CreateCommentParams, CreateCommentResponse>
8282
request: {
8383
url: (params) => {
8484
if (params.path) {
85-
return `https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/pulls/${safeUrlPathSegment(String(params.pullNumber), 'pullNumber')}/comments`
85+
return `https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/pulls/${safeUrlPathSegment(params.pullNumber, 'pullNumber')}/comments`
8686
}
87-
return `https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/pulls/${safeUrlPathSegment(String(params.pullNumber), 'pullNumber')}/reviews`
87+
return `https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/pulls/${safeUrlPathSegment(params.pullNumber, 'pullNumber')}/reviews`
8888
},
8989
method: 'POST',
9090
headers: (params) => ({

apps/sim/tools/github/create_comment_reaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const createCommentReactionTool: ToolConfig<
6868

6969
request: {
7070
url: (params) =>
71-
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/issues/comments/${safeUrlPathSegment(String(params.comment_id), 'comment_id')}/reactions`,
71+
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/issues/comments/${safeUrlPathSegment(params.comment_id, 'comment_id')}/reactions`,
7272
method: 'POST',
7373
headers: (params) => ({
7474
Accept: 'application/vnd.github.squirrel-girl-preview+json',

apps/sim/tools/github/create_issue_reaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const createIssueReactionTool: ToolConfig<
6868

6969
request: {
7070
url: (params) =>
71-
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/issues/${safeUrlPathSegment(String(params.issue_number), 'issue_number')}/reactions`,
71+
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/issues/${safeUrlPathSegment(params.issue_number, 'issue_number')}/reactions`,
7272
method: 'POST',
7373
headers: (params) => ({
7474
Accept: 'application/vnd.github.squirrel-girl-preview+json',

apps/sim/tools/github/create_pr_review.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export const createPRReviewTool: ToolConfig<CreatePRReviewParams, PRReviewRespon
160160

161161
request: {
162162
url: (params) =>
163-
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/pulls/${safeUrlPathSegment(String(params.pullNumber), 'pullNumber')}/reviews`,
163+
`https://api.github.com/repos/${safeUrlPathSegment(params.owner, 'owner')}/${safeUrlPathSegment(params.repo, 'repo')}/pulls/${safeUrlPathSegment(params.pullNumber, 'pullNumber')}/reviews`,
164164
method: 'POST',
165165
headers: (params) => ({
166166
Accept: 'application/vnd.github+json',

0 commit comments

Comments
 (0)