SCAL-333947 : Parma - #654
Open
sastaachar wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces the reconcileRuntimeParams method to update runtime filters during parameter updates. A potential runtime TypeError was identified where getPreRenderObj() could return undefined, and it is recommended to use optional chaining to safely access its properties.
Comment on lines
+2046
to
+2054
| const prevPreRenderConfigs = this.getPreRenderObj(); | ||
| if (prevPreRenderConfigs.viewConfig.runtimeFilters) { | ||
| this.trigger(HostEvent.UpdateRuntimeFilters, prevPreRenderConfigs.viewConfig.runtimeFilters.map((filter) => { | ||
| return { | ||
| ...filter, | ||
| values: [] | ||
| } | ||
| })); | ||
| } |
Contributor
There was a problem hiding this comment.
If getPreRenderObj() returns undefined (e.g., when there is no active pre-rendered wrapper), accessing prevPreRenderConfigs.viewConfig will throw a TypeError and crash the application.
Using optional chaining (?.) prevents this runtime error. Additionally, the .map() callback can be simplified to use an implicit return for better readability.
const prevPreRenderConfigs = this.getPreRenderObj();
if (prevPreRenderConfigs?.viewConfig?.runtimeFilters) {
this.trigger(
HostEvent.UpdateRuntimeFilters,
prevPreRenderConfigs.viewConfig.runtimeFilters.map((filter) => ({
...filter,
values: [],
})),
);
}…ests reconcileRuntimeParams triggers UpdateRuntimeFilters after UpdateEmbedParams, so UpdateEmbedParams is no longer the last processTrigger call. Two showPreRender tests asserted it with toHaveBeenLastCalledWith and failed; they now assert the same payload with toHaveBeenCalledWith. Make the fallback branch null-safe. getPreRenderObj() reads an untyped property off the pre-render wrapper node, so it can return an object with no viewConfig; reading viewConfig.runtimeFilters off it threw a TypeError that the surrounding catch turned into a logger.error, which jest-setup escalates to a fatal error and surfaced on an unrelated liveboard.spec test. Add coverage for the three reconcile paths — filters from the new config, clearing the filters left by the previous config, and no filters at all — plus the missing-viewConfig case. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
commit: |
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.
No description provided.