fix(ui): harden the Slack channel listing against malformed pages

- Keep already-read channel pages when a later page answers a 5xx
- Skip channel resources without a usable id
- Flatten the PATCH body test interface per TypeScript guidelines
This commit is contained in:
Pablo F.G
2026-08-19 08:44:36 +02:00
parent 7da6d06f51
commit fb6f7ed9c9
2 changed files with 30 additions and 6 deletions
+17 -5
View File
@@ -342,10 +342,18 @@ export const getSlackChannels = async (
});
if (!response.ok) {
const message = await errorMessageFrom(
response,
`Unable to read the workspace's channels: ${response.statusText}`,
);
let message: string;
try {
message = await errorMessageFrom(
response,
`Unable to read the workspace's channels: ${response.statusText}`,
);
} catch (error) {
// `handleApiResponse` reported the 5xx and threw; a first-page
// failure stays a failure, but later pages keep what was read.
if (channels.length === 0) throw error;
return { channels, incomplete: SLACK_GENERIC_ERROR_MESSAGE };
}
return channels.length > 0
? { channels, incomplete: message }
@@ -357,8 +365,12 @@ export const getSlackChannels = async (
const body = await response.json().catch(() => null);
for (const resource of body?.data ?? []) {
// Radix `Select.Item` refuses an empty value; one malformed resource
// would break the whole picker.
const channelId = resource?.id;
if (typeof channelId !== "string" || channelId.length === 0) continue;
channels.push({
id: resource?.id,
id: channelId,
name: resource?.attributes?.name ?? "",
is_private: Boolean(resource?.attributes?.is_private),
});
@@ -39,7 +39,19 @@ import {
/** The shape the channel save is asserted against — only the id travels. */
interface PatchIntegrationBody {
data: { attributes: { configuration: { channel_id: string } } };
data: PatchIntegrationData;
}
interface PatchIntegrationData {
attributes: PatchIntegrationAttributes;
}
interface PatchIntegrationAttributes {
configuration: PatchChannelConfiguration;
}
interface PatchChannelConfiguration {
channel_id: string;
}
/** The workspace the fixtures connect. */