Skip to content

Commit 441d2a6

Browse files
committed
fix(connectors): address second round of PR review comments
- OneDrive: use Buffer.subarray for byte-accurate truncation instead of character-count slice - Reddit: deduplicate comment extraction — fetchPostComments now calls extractComments instead of duplicating the logic - Webflow: replace crude value.includes('<') with regex /<[a-z][^>]*>/i to avoid false positives on plain text containing '<' - Jira: add response.ok check in getJiraCloudId before parsing JSON to surface real HTTP errors instead of misleading "No Jira resources found"
1 parent 5273649 commit 441d2a6

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

apps/sim/connectors/onedrive/onedrive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async function downloadFileContent(accessToken: string, fileId: string): Promise
7272

7373
const text = await response.text()
7474
if (Buffer.byteLength(text, 'utf8') > MAX_FILE_SIZE) {
75-
return text.slice(0, MAX_FILE_SIZE)
75+
return Buffer.from(text, 'utf8').subarray(0, MAX_FILE_SIZE).toString('utf8')
7676
}
7777
return text
7878
}

apps/sim/connectors/reddit/reddit.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,7 @@ async function fetchPostComments(
103103

104104
if (!Array.isArray(data) || data.length < 2) return []
105105

106-
const commentListing = data[1]
107-
const comments: string[] = []
108-
109-
for (const child of commentListing.data.children) {
110-
if (child.kind !== 't1') continue
111-
const comment = child as RedditComment
112-
if (!comment.data.body || comment.data.author === 'AutoModerator') continue
113-
comments.push(`[${comment.data.author} | score: ${comment.data.score}]: ${comment.data.body}`)
114-
if (comments.length >= maxComments) break
115-
}
116-
117-
return comments
106+
return extractComments(data[1], maxComments)
118107
} catch (error) {
119108
logger.warn('Failed to fetch comments for post', {
120109
postId,

apps/sim/connectors/webflow/webflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function itemToPlainText(item: WebflowItem, collectionName: string): string {
6060
lines.push(`${key}: ${items.join(', ')}`)
6161
} else if (typeof value === 'object') {
6262
lines.push(`${key}: ${JSON.stringify(value)}`)
63-
} else if (typeof value === 'string' && value.includes('<')) {
63+
} else if (typeof value === 'string' && /<[a-z][^>]*>/i.test(value)) {
6464
lines.push(`${key}: ${htmlToPlainText(value)}`)
6565
} else {
6666
lines.push(`${key}: ${String(value)}`)

apps/sim/tools/jira/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ export async function getJiraCloudId(domain: string, accessToken: string): Promi
109109
}
110110
)
111111

112+
if (!response.ok) {
113+
const errorText = await response.text()
114+
throw new Error(`Failed to fetch Jira accessible resources: ${response.status} - ${errorText}`)
115+
}
116+
112117
const resources = await response.json()
113118

114119
if (Array.isArray(resources) && resources.length > 0) {

0 commit comments

Comments
 (0)