Skip to content

Commit c307e6d

Browse files
committed
fix(helpscout): keep bracketed tags on the comma-separated path and clear only on a literal []
1 parent be963da commit c307e6d

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

‎apps/sim/tools/helpscout/set-conversation-tags.ts‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { toStringOrNull } from '@sim/utils/coerce'
12
import { ErrorExtractorId } from '@/tools/error-extractors'
23
import type {
34
HelpScoutConversationChangeResponse,
@@ -10,22 +11,15 @@ import {
1011
CONVERSATION_ID_PARAM,
1112
conversationChangeResult,
1213
conversationUrl,
13-
parseJsonParam,
1414
toStringList,
1515
} from '@/tools/helpscout/utils'
1616
import type { ToolConfig } from '@/tools/types'
1717

1818
/** An empty list removes every tag, so clearing takes an explicit `[]` and never an omitted value. */
1919
function parseTags(value: unknown): string[] {
20-
const parsed =
21-
typeof value === 'string' && value.trim().startsWith('[')
22-
? parseJsonParam(value, 'tags')
23-
: value
24-
const tags = toStringList(parsed)
25-
const clearsEveryTag = Array.isArray(parsed) && parsed.length === 0
26-
if (tags.length === 0 && !clearsEveryTag) {
27-
throw new Error('tags is empty; pass [] to remove every tag')
28-
}
20+
if (Array.isArray(value) ? value.length === 0 : toStringOrNull(value)?.trim() === '[]') return []
21+
const tags = toStringList(value)
22+
if (tags.length === 0) throw new Error('tags is empty; pass [] to remove every tag')
2923
return tags
3024
}
3125

0 commit comments

Comments
 (0)