Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(ci): fix storyTitle array crash in PR comment generation (#390)

Cindy Zhang822b74ff834f
diff --git a/.github/scripts/analyze-pr.js b/.github/scripts/analyze-pr.js
index 5c00891a0d..08b47d895b 100644
--- a/.github/scripts/analyze-pr.js
+++ b/.github/scripts/analyze-pr.js
@@ -211,7 +211,10 @@ function getStoryTitle(componentName) {
return titleMatch ? titleMatch[1] : null;
}).filter(Boolean);
- return titles.length === 1 ? titles[0] : titles.length > 0 ? titles : null;
+ // Always return a single string (first match) or null — never an array.
+ // Multiple story files may match (e.g. Popover.stories.tsx + PopoverFilter.stories.tsx),
+ // but downstream code expects a string for Storybook link generation.
+ return titles.length > 0 ? titles[0] : null;
} catch {
return null;
}
diff --git a/.github/scripts/generate-pr-comment.js b/.github/scripts/generate-pr-comment.js
index 93ea93e772..7f75235f07 100644
--- a/.github/scripts/generate-pr-comment.js
+++ b/.github/scripts/generate-pr-comment.js
@@ -57,7 +57,7 @@ try {
// Build a Storybook deep link URL for a component
// Story titles like "Core/XDSButton" become path "/docs/core-xdsbutton--docs"
function getStorybookLink(storybookBaseUrl, storyTitle) {
- if (!storybookBaseUrl || !storyTitle) return null;
+ if (!storybookBaseUrl || !storyTitle || typeof storyTitle !== 'string') return null;
// Storybook converts "Core/XDSButton" to "core-xdsbutton" as the story ID prefix
const storyPath = storyTitle.toLowerCase().replace(/\//g, '-');
return `${storybookBaseUrl}?path=/docs/${storyPath}--docs`;