frontend: storybook: Fix startup failure caused by node story helpers#6126
Merged
illume merged 1 commit intoJun 22, 2026
Merged
Conversation
Storybook startup failed with "Cannot access 'KubeObject' before initialization" because baseMocks imported node/storyHelper, which loaded node.ts at runtime only to access NODE_POOL_LABEL_KEYS and type definitions. Extract NODE_POOL_LABEL_KEYS into a dedicated nodeConstants module and update storyHelper to use type-only imports, avoiding an unnecessary runtime dependency on the Node implementation. Re-export NODE_POOL_LABEL_KEYS from node.ts to preserve plugin and consumer compatibility. Signed-off-by: mahesh-09-12 <m8143177@gmail.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: illume, mahesh-09-12 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a Storybook startup failure caused by an unnecessary runtime dependency on the Node implementation.
Storybook failed to start and all stories remained stuck loading, with the browser console reporting:
Investigation showed that Storybook's
baseMocksimportednode/storyHelper, which importedNODE_POOL_LABEL_KEYSand type definitions fromnode.ts. AlthoughstoryHelperonly needed a constant and type information, importing fromnode.tscaused the entire Node/KubeObject dependency graph to be evaluated during Storybook startup, leading to the initialization error.This PR extracts
NODE_POOL_LABEL_KEYSinto a dedicated constants module and updatesstoryHelperto use type-only imports, avoiding the unnecessary runtime dependency while preserving existing public exports.Related Issue
Fixes #6125
Changes
Added
src/lib/k8s/nodeConstants.tsand movedNODE_POOL_LABEL_KEYSinto it.Updated
src/components/node/storyHelper.tsto:KubeNodeandKubeMetrics.NODE_POOL_LABEL_KEYSdirectly fromnodeConstants.ts.Re-exported
NODE_POOL_LABEL_KEYSfromsrc/lib/k8s/node.tsto preserve plugin and consumer compatibility.Added documentation around the re-export explaining its purpose.
Steps to Test
Start Storybook before applying the fix.
Observe that Storybook fails to load and the browser console reports:
Apply the changes from this PR.
Start Storybook again.
Verify that Storybook loads successfully and stories render normally.
Additionally verify:
npm run tsc npm run lint npm testAll pass successfully.
Screenshots
Before
Storybook failed to load and remained stuck rendering stories. The browser console reported:
After
Storybook starts successfully and stories render normally.
Notes for the Reviewer
NODE_POOL_LABEL_KEYScontinues to be exported fromnode.tsto maintain plugin compatibility and avoid breaking existing consumers.