Skip to content

SCAL-333947 : Parma - #654

Open
sastaachar wants to merge 3 commits into
mainfrom
SCAL-333947
Open

SCAL-333947 : Parma#654
sastaachar wants to merge 3 commits into
mainfrom
SCAL-333947

Conversation

@sastaachar

Copy link
Copy Markdown
Contributor

No description provided.

@sastaachar
sastaachar requested a review from a team as a code owner September 3, 2026 08:54

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread src/embed/ts-embed.ts Outdated
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: []
}
}));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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: [],
                })),
            );
        }

sastaachar and others added 2 commits September 3, 2026 14:27
…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>
@pkg-pr-new

pkg-pr-new Bot commented Sep 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@thoughtspot/visual-embed-sdk@654

commit: 9a60baa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant