Summary
When a user edits an existing Chaos Experiment (StudioOverview / ChaosInfrastructureReferenceField), the pre-selected target Kubernetes Chaos Infrastructure field renders empty if the target infrastructure is not located on the first page of the paginated listInfras GraphQL query results.
Steps to Reproduce
- Navigate to a project in Litmus Chaos Center.
- Ensure there are multiple target Chaos Infrastructures (or change pagination limits/search filters such that a specific infrastructure is not on page 1).
- Create a Chaos Experiment utilizing that specific target infrastructure.
- Open the experiment in Edit Mode (
StudioOverview).
- Observe the Target Infrastructure reference field.
Expected Behavior
The target infrastructure field should correctly display the pre-selected infrastructure (initialInfrastructureID) regardless of whether it appears on the current page of the paginated list query.
Actual Behavior
The target infrastructure reference field appears completely empty during edit mode, as noted by the existing TODO in codebase:
// TODO: replace with get API as this becomes empty during edit inside KubernetesChaosInfrastructureReferenceField.tsx.
Root Cause
KubernetesChaosInfrastructureReferenceFieldController previously attempted to find the initial infrastructure solely by searching within listChaosInfraData?.listInfras.infras.find(). Because listChaosInfra is paginated (page: 0, limit: 5), any infrastructure not present in the current page slice causes .find() to return undefined.
Proposed Solution
Fetch the specific infrastructure details directly by ID using the backend's getInfraDetails(projectID: $projectID, infraID: $infraID) GraphQL query whenever initialInfrastructureID is provided, and fallback/merge with the paginated list results.
Summary
When a user edits an existing Chaos Experiment (
StudioOverview/ChaosInfrastructureReferenceField), the pre-selected target Kubernetes Chaos Infrastructure field renders empty if the target infrastructure is not located on the first page of the paginatedlistInfrasGraphQL query results.Steps to Reproduce
StudioOverview).Expected Behavior
The target infrastructure field should correctly display the pre-selected infrastructure (
initialInfrastructureID) regardless of whether it appears on the current page of the paginated list query.Actual Behavior
The target infrastructure reference field appears completely empty during edit mode, as noted by the existing
TODOin codebase:// TODO: replace with get API as this becomes empty during editinsideKubernetesChaosInfrastructureReferenceField.tsx.Root Cause
KubernetesChaosInfrastructureReferenceFieldControllerpreviously attempted to find the initial infrastructure solely by searching withinlistChaosInfraData?.listInfras.infras.find(). BecauselistChaosInfrais paginated (page: 0, limit: 5), any infrastructure not present in the current page slice causes.find()to returnundefined.Proposed Solution
Fetch the specific infrastructure details directly by ID using the backend's
getInfraDetails(projectID: $projectID, infraID: $infraID)GraphQL query wheneverinitialInfrastructureIDis provided, and fallback/merge with the paginated list results.