Skip to content

Commit 46fda04

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(confluence): hydrate legacy numeric space selections
1 parent 1a7e773 commit 46fda04

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

apps/sim/lib/selectors/server/providers/confluence.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,25 @@ describe('Confluence server selector adapters', () => {
127127
expect(String(mockFetch.mock.calls[0]?.[0])).toContain('/wiki/api/v2/spaces/12345')
128128
})
129129

130+
it('hydrates a legacy numeric value in the key selector without rewriting it', async () => {
131+
mockFetch.mockResolvedValueOnce(
132+
new Response(JSON.stringify({ id: '12345', key: 'ENG', name: 'Engineering' }), {
133+
status: 200,
134+
})
135+
)
136+
137+
await expect(
138+
confluenceSelectorAttachments['confluence.spaces'].execute({
139+
...spaceDetailArgs(),
140+
request: { kind: 'detail', id: '12345' },
141+
})
142+
).resolves.toEqual({
143+
kind: 'detail',
144+
item: { id: '12345', label: 'Engineering (ENG)' },
145+
})
146+
expect(String(mockFetch.mock.calls[0]?.[0])).toContain('/wiki/api/v2/spaces/12345')
147+
})
148+
130149
it('projects provider IDs for block space lists while key selectors remain unchanged', async () => {
131150
mockFetch
132151
.mockResolvedValueOnce(

apps/sim/lib/selectors/server/providers/confluence.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ async function executeSpaces(args: ExecuteServerSelectorArgs, identifier: 'key'
124124
if (args.request.kind === 'detail') {
125125
const requestedId = args.request.id.trim()
126126
if (!requestedId || requestedId.length > 255) throw new SelectorContextUnavailableError()
127-
if (identifier === 'id' && /^[1-9][0-9]{0,19}$/.test(requestedId)) {
127+
if (/^[1-9][0-9]{0,19}$/.test(requestedId)) {
128128
const space = await fetchProviderJson<ConfluenceSpace>(
129129
`https://api.atlassian.com/ex/confluence/${auth.cloudId}/wiki/api/v2/spaces/${requestedId}`,
130130
{
@@ -133,7 +133,10 @@ async function executeSpaces(args: ExecuteServerSelectorArgs, identifier: 'key'
133133
}
134134
)
135135
if (!space.id || !space.key || !space.name) throw new SelectorOptionsUnavailableError()
136-
return detailSelectorResult(spaceOption(space, space.status ?? 'current', 'id'))
136+
return detailSelectorResult({
137+
...spaceOption(space, space.status ?? 'current', identifier),
138+
id: requestedId,
139+
})
137140
}
138141

139142
const key = requestedId

0 commit comments

Comments
 (0)