Skip to content

Commit f157350

Browse files
jeroenterheerdtJeroen ter Heerdt
authored andcommitted
fix(integrations): forward integration config to outbound hooks
getIntegrationTargets() only passed {accessToken, rootUrl} into each hook's config, dropping integration-specific fields stored in integrations.config (organizationName, cloudId, teamId, etc). Azure DevOps work item creation failed with a misleading "reconnect" auth error because organizationName never reached createWorkItem() - same gap affects Jira/Teams/Monday/Trello/Asana. Also stop discarding the Azure DevOps API response body on failure, so future errors log the actual validation message instead of a bare status code.
1 parent 456a296 commit f157350

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

apps/web/src/lib/server/events/targets.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,15 +317,18 @@ async function getIntegrationTargets(
317317
const secrets = decryptSecrets<{ accessToken?: string }>(m.secrets)
318318
accessToken = secrets.accessToken
319319
} catch (error) {
320-
log.error({ err: error, integration_type: m.integrationType }, 'failed to decrypt integration secrets')
320+
log.error(
321+
{ err: error, integration_type: m.integrationType },
322+
'failed to decrypt integration secrets'
323+
)
321324
continue
322325
}
323326
}
324327

325328
targets.push({
326329
type: m.integrationType,
327330
target: { channelId },
328-
config: { accessToken, rootUrl: context.portalBaseUrl },
331+
config: { ...integrationConfig, accessToken, rootUrl: context.portalBaseUrl },
329332
})
330333
}
331334

apps/web/src/lib/server/integrations/azure-devops/api.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ async function azureDevOpsApi(
3636

3737
if (!response.ok) {
3838
const status = response.status
39-
if (status === 401) throw Object.assign(new Error('Unauthorized'), { status })
40-
if (status === 403) throw Object.assign(new Error('Forbidden'), { status })
41-
if (status === 429) throw Object.assign(new Error('Rate limited'), { status })
42-
if (status >= 500) throw Object.assign(new Error(`Server error ${status}`), { status })
43-
throw Object.assign(new Error(`HTTP ${status}`), { status })
39+
const detail = await response.text().catch(() => '')
40+
if (status === 401) throw Object.assign(new Error('Unauthorized'), { status, detail })
41+
if (status === 403) throw Object.assign(new Error('Forbidden'), { status, detail })
42+
if (status === 429) throw Object.assign(new Error('Rate limited'), { status, detail })
43+
if (status >= 500) throw Object.assign(new Error(`Server error ${status}`), { status, detail })
44+
throw Object.assign(new Error(`HTTP ${status}: ${detail}`), { status, detail })
4445
}
4546

4647
return response

0 commit comments

Comments
 (0)