Skip to content

Commit 51e3768

Browse files
authored
fix(linear): updated linear tools to enforce only required fields per api spec (#2845)
1 parent feb994c commit 51e3768

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

apps/sim/blocks/blocks/linear.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,10 @@ Return ONLY the comment text - no explanations.`,
417417
title: 'Name',
418418
type: 'short-input',
419419
placeholder: 'Enter name',
420-
required: true,
420+
required: {
421+
field: 'operation',
422+
value: ['linear_create_label', 'linear_create_project', 'linear_create_workflow_state'],
423+
},
421424
condition: {
422425
field: 'operation',
423426
value: [
@@ -550,6 +553,10 @@ Return ONLY the search query - no explanations.`,
550553
title: 'Start Date',
551554
type: 'short-input',
552555
placeholder: 'YYYY-MM-DD',
556+
required: {
557+
field: 'operation',
558+
value: ['linear_create_cycle'],
559+
},
553560
condition: {
554561
field: 'operation',
555562
value: ['linear_create_cycle', 'linear_create_project'],
@@ -573,6 +580,7 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n
573580
title: 'End Date',
574581
type: 'short-input',
575582
placeholder: 'YYYY-MM-DD',
583+
required: true,
576584
condition: {
577585
field: 'operation',
578586
value: ['linear_create_cycle'],
@@ -1407,13 +1415,10 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n
14071415
// Operation-specific param mapping
14081416
switch (params.operation) {
14091417
case 'linear_read_issues':
1410-
if (!effectiveTeamId || !effectiveProjectId) {
1411-
throw new Error('Team ID and Project ID are required.')
1412-
}
14131418
return {
14141419
...baseParams,
1415-
teamId: effectiveTeamId,
1416-
projectId: effectiveProjectId,
1420+
teamId: effectiveTeamId || undefined,
1421+
projectId: effectiveProjectId || undefined,
14171422
includeArchived: params.includeArchived,
14181423
}
14191424

@@ -1427,16 +1432,16 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n
14271432
}
14281433

14291434
case 'linear_create_issue':
1430-
if (!effectiveTeamId || !effectiveProjectId) {
1431-
throw new Error('Team ID and Project ID are required.')
1435+
if (!effectiveTeamId) {
1436+
throw new Error('Team ID is required.')
14321437
}
14331438
if (!params.title?.trim()) {
14341439
throw new Error('Title is required.')
14351440
}
14361441
return {
14371442
...baseParams,
14381443
teamId: effectiveTeamId,
1439-
projectId: effectiveProjectId,
1444+
projectId: effectiveProjectId || undefined,
14401445
title: params.title.trim(),
14411446
description: params.description,
14421447
stateId: params.stateId,
@@ -1504,13 +1509,13 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n
15041509
}
15051510

15061511
case 'linear_update_comment':
1507-
if (!params.commentId?.trim() || !params.body?.trim()) {
1508-
throw new Error('Comment ID and body are required.')
1512+
if (!params.commentId?.trim()) {
1513+
throw new Error('Comment ID is required.')
15091514
}
15101515
return {
15111516
...baseParams,
15121517
commentId: params.commentId.trim(),
1513-
body: params.body.trim(),
1518+
body: params.body?.trim() || undefined,
15141519
}
15151520

15161521
case 'linear_delete_comment':
@@ -1637,15 +1642,12 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n
16371642
if (!effectiveTeamId || !params.name?.trim() || !params.workflowType) {
16381643
throw new Error('Team ID, name, and workflow type are required.')
16391644
}
1640-
if (!params.color?.trim()) {
1641-
throw new Error('Color is required for workflow state creation.')
1642-
}
16431645
return {
16441646
...baseParams,
16451647
teamId: effectiveTeamId,
16461648
name: params.name.trim(),
16471649
type: params.workflowType,
1648-
color: params.color.trim(),
1650+
color: params.color?.trim() || undefined,
16491651
}
16501652

16511653
case 'linear_update_workflow_state':
@@ -1675,15 +1677,15 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n
16751677
}
16761678

16771679
case 'linear_create_cycle':
1678-
if (!effectiveTeamId || !params.name?.trim()) {
1679-
throw new Error('Team ID and cycle name are required.')
1680+
if (!effectiveTeamId || !params.startDate?.trim() || !params.endDate?.trim()) {
1681+
throw new Error('Team ID, start date, and end date are required.')
16801682
}
16811683
return {
16821684
...baseParams,
16831685
teamId: effectiveTeamId,
1684-
name: params.name.trim(),
1685-
startsAt: params.startDate,
1686-
endsAt: params.endDate,
1686+
name: params.name?.trim() || undefined,
1687+
startsAt: params.startDate.trim(),
1688+
endsAt: params.endDate.trim(),
16871689
}
16881690

16891691
case 'linear_get_active_cycle':

0 commit comments

Comments
 (0)