Skip to content

Commit 8437acf

Browse files
committed
fix(clickup): integer-only maxDocs and location filters, depth-aware doc headings, most-specific-location hints
1 parent 874791e commit 8437acf

4 files changed

Lines changed: 24 additions & 14 deletions

File tree

apps/sim/connectors/clickup/clickup.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,15 @@ function parsePage(value: unknown): ClickUpDocPage | null {
9696
* Flattens a Doc's page tree depth-first into markdown sections, skipping
9797
* deleted and archived pages (their subpages are skipped with them).
9898
*/
99-
function flattenPages(pages: ClickUpDocPage[], sections: string[]): void {
99+
function flattenPages(pages: ClickUpDocPage[], sections: string[], depth = 0): void {
100+
const heading = '#'.repeat(Math.min(depth + 1, 6))
100101
for (const page of pages) {
101102
if (page.deleted || page.archived) continue
102103
const parts: string[] = []
103-
if (page.name.trim()) parts.push(`# ${page.name.trim()}`)
104+
if (page.name.trim()) parts.push(`${heading} ${page.name.trim()}`)
104105
if (page.content.trim()) parts.push(page.content.trim())
105106
if (parts.length > 0) sections.push(parts.join('\n\n'))
106-
flattenPages(page.pages, sections)
107+
flattenPages(page.pages, sections, depth + 1)
107108
}
108109
}
109110

@@ -169,7 +170,7 @@ export const clickupConnector: ConnectorConfig = {
169170
typeof sourceConfig.spaceId === 'string' && sourceConfig.spaceId.trim()
170171
? sourceConfig.spaceId.trim()
171172
: undefined
172-
const maxDocs = sourceConfig.maxDocs ? Number(sourceConfig.maxDocs) : 0
173+
const maxDocs = sourceConfig.maxDocs ? Math.floor(Number(sourceConfig.maxDocs)) : 0
173174

174175
const url = buildSearchDocsUrl(workspaceId, { spaceId, limit: LIST_PAGE_SIZE, cursor })
175176
const response = await fetchWithRetry(url, {
@@ -271,8 +272,8 @@ export const clickupConnector: ConnectorConfig = {
271272
}
272273

273274
const maxDocs = sourceConfig.maxDocs as string | undefined
274-
if (maxDocs && (Number.isNaN(Number(maxDocs)) || Number(maxDocs) <= 0)) {
275-
return { valid: false, error: 'Max docs must be a positive number' }
275+
if (maxDocs && (!Number.isInteger(Number(maxDocs)) || Number(maxDocs) <= 0)) {
276+
return { valid: false, error: 'Max docs must be a positive whole number' }
276277
}
277278

278279
const spaceId =

apps/sim/lib/webhooks/providers/clickup.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,17 @@ describe('ClickUp webhook provider', () => {
315315
expect(deleteInit.method).toBe('DELETE')
316316
})
317317

318-
it('rejects non-numeric location filters before calling ClickUp', async () => {
318+
it('rejects non-integer location filters before calling ClickUp', async () => {
319319
await expect(
320320
clickupHandler.createSubscription!(
321321
createContext({ ...validConfig, triggerSpaceId: 'not-a-number' })
322322
)
323-
).rejects.toThrow(/Space ID must be numeric/)
323+
).rejects.toThrow(/Space ID must be a whole number/)
324+
await expect(
325+
clickupHandler.createSubscription!(
326+
createContext({ ...validConfig, triggerSpaceId: '12.5' })
327+
)
328+
).rejects.toThrow(/Space ID must be a whole number/)
324329
expect(fetchMock).not.toHaveBeenCalled()
325330
})
326331
})

apps/sim/lib/webhooks/providers/clickup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ function parseOptionalNumericId(value: unknown, label: string): number | undefin
7474
const raw = String(value).trim()
7575
if (!raw) return undefined
7676
const parsed = Number(raw)
77-
if (!Number.isFinite(parsed)) {
78-
throw new Error(`ClickUp ${label} must be numeric. Received: ${raw}`)
77+
if (!Number.isInteger(parsed)) {
78+
throw new Error(`ClickUp ${label} must be a whole number. Received: ${raw}`)
7979
}
8080
return parsed
8181
}

apps/sim/triggers/clickup/subblocks.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ export function buildClickUpTriggerSubBlocks(triggerId: string): SubBlockConfig[
6969
title: 'Space ID (Optional)',
7070
type: 'short-input',
7171
placeholder: 'Leave empty for the entire workspace',
72-
description: 'Only receive events from this space',
72+
description:
73+
'Only receive events from this space. ClickUp applies the most specific location when several are set',
7374
mode: 'trigger',
7475
condition: { field: 'selectedTriggerId', value: triggerId },
7576
},
@@ -78,7 +79,8 @@ export function buildClickUpTriggerSubBlocks(triggerId: string): SubBlockConfig[
7879
title: 'Folder ID (Optional)',
7980
type: 'short-input',
8081
placeholder: 'Leave empty for the entire workspace',
81-
description: 'Only receive events from this folder',
82+
description:
83+
'Only receive events from this folder. ClickUp applies the most specific location when several are set',
8284
mode: 'trigger',
8385
condition: { field: 'selectedTriggerId', value: triggerId },
8486
},
@@ -87,7 +89,8 @@ export function buildClickUpTriggerSubBlocks(triggerId: string): SubBlockConfig[
8789
title: 'List ID (Optional)',
8890
type: 'short-input',
8991
placeholder: 'Leave empty for the entire workspace',
90-
description: 'Only receive events from this list',
92+
description:
93+
'Only receive events from this list. ClickUp applies the most specific location when several are set',
9194
mode: 'trigger',
9295
condition: { field: 'selectedTriggerId', value: triggerId },
9396
},
@@ -96,7 +99,8 @@ export function buildClickUpTriggerSubBlocks(triggerId: string): SubBlockConfig[
9699
title: 'Task ID (Optional)',
97100
type: 'short-input',
98101
placeholder: 'Leave empty for the entire workspace',
99-
description: 'Only receive events for this task',
102+
description:
103+
'Only receive events for this task. ClickUp applies the most specific location when several are set',
100104
mode: 'trigger',
101105
condition: { field: 'selectedTriggerId', value: triggerId },
102106
},

0 commit comments

Comments
 (0)