Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(control-ui): r3-l3 retain credential failure context

Josuéa8599e0f7ced
diff --git a/control-ui/app/communication-channels/[name]/edit/page.tsx b/control-ui/app/communication-channels/[name]/edit/page.tsx
index e349379f3..a155b23ad 100644
--- a/control-ui/app/communication-channels/[name]/edit/page.tsx
+++ b/control-ui/app/communication-channels/[name]/edit/page.tsx
@@ -378,6 +378,7 @@ export default function EditCommunicationChannelPage() {
setSaveError('')
let mutationCommitted = saveRefreshPending
let channelSettingsSaved = false
+ const failedLabels: string[] = []
try {
if (specDirty) {
await apiSend('PUT', `/api/v1/admin/communication-channels/${encodeURIComponent(name)}`, {
@@ -416,7 +417,6 @@ export default function EditCommunicationChannelPage() {
}
const successful: CredentialKey[] = []
- const failedLabels: string[] = []
for (const operation of validatedPlan.operations) {
try {
if (operation.kind === 'replace') {
@@ -467,7 +467,12 @@ export default function EditCommunicationChannelPage() {
showToast(`Communication channel ${name} updated.`, { tone: 'success' })
backToChannels()
} catch (error) {
- if (mutationCommitted) {
+ if (failedLabels.length) {
+ const refreshError = error instanceof Error ? error.message : 'refresh failed'
+ setSaveError(
+ `${channelSettingsSaved ? 'Channel settings were saved, but ' : ''}credential changes failed for: ${failedLabels.join(', ')}. The authoritative refresh also failed: ${refreshError}. Retry Save to apply remaining changes and refresh.`
+ )
+ } else if (mutationCommitted) {
setSaveRefreshPending(true)
setSaveError(
'Channel settings were saved, but the authoritative refresh failed. Retry Save to refresh without resending successful credential changes.'
diff --git a/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx b/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx
index a86b1e46c..bc0aa58d9 100644
--- a/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx
+++ b/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx
@@ -444,11 +444,51 @@ describe('EditCommunicationChannelPage channel credentials', () => {
fireEvent.click(screen.getByRole('button', { name: 'Save changes' }))
const alert = await screen.findByRole('alert')
- expect(alert).toHaveTextContent(/credential changes failed: Slack Bot User OAuth Token/i)
+ expect(alert).toHaveTextContent(/some credential changes failed: Slack Bot User OAuth Token/i)
expect(alert).not.toHaveTextContent(/channel settings were saved/i)
expect(api.apiSend).toHaveBeenCalledTimes(1)
expect(navigation.push).not.toHaveBeenCalled()
})
+
+ it('retains credential and refresh failures in the same save error', async () => {
+ const channel = 'credential-and-refresh-failure'
+ navigation.params = { name: channel }
+ let channelReads = 0
+ vi.mocked(api.apiGet).mockImplementation(async path => {
+ if (path === '/api/v1/admin/hosts') {
+ return { items: [{ metadata: { name: 'agent-a' } }] }
+ }
+ if (path === `/api/v1/admin/communication-channels/${channel}/credentials`) {
+ return { keys: [] }
+ }
+ if (path === `/api/v1/admin/communication-channels/${channel}`) {
+ channelReads += 1
+ if (channelReads === 3) throw new Error('authoritative channel refresh failed')
+ return {
+ item: {
+ metadata: { name: channel, namespace: 'channels' },
+ spec: { access: { users: [], teams: [] }, hostRef: 'agent-a', ...SLACK_CHANNEL_SPEC },
+ },
+ }
+ }
+ return { items: [] }
+ })
+ vi.mocked(api.apiSend).mockRejectedValue(new Error('credential write failed'))
+ await renderLoadedPage()
+ fireEvent.click(screen.getByRole('radio', { name: 'Slack' }))
+ fireEvent.change(screen.getByLabelText('Slack Bot User OAuth Token'), {
+ target: { value: 'bot-token-draft' },
+ })
+
+ fireEvent.click(screen.getByRole('button', { name: 'Save changes' }))
+
+ const alert = await screen.findByRole('alert')
+ expect(alert).toHaveTextContent(/credential changes failed for: Slack Bot User OAuth Token/i)
+ expect(alert).toHaveTextContent(/authoritative refresh also failed/i)
+ expect(alert).toHaveTextContent(/authoritative channel refresh failed/i)
+ expect(api.apiSend).toHaveBeenCalledTimes(1)
+ expect(navigation.push).not.toHaveBeenCalled()
+ })
})
/** Both strings are written out rather than imported: this copy IS the feature,
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index ee59e5faf..9b6b51d1a 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.646",
+ "version": "0.1.647",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.646",
+ "version": "0.1.647",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/frontend-components": "file:../packages/frontend-components",
diff --git a/control-ui/package.json b/control-ui/package.json
index 6dbe50fc7..abd805a38 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.646",
+ "version": "0.1.647",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",