-
Notifications
You must be signed in to change notification settings - Fork 31
ci(node-server-sdk): put in contract test workaround #1085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -328,9 +328,22 @@ export async function newSdkClientEntity(options: any): Promise<SdkClientEntity> | |
| options.configuration.startWaitTimeMs !== undefined | ||
| ? options.configuration.startWaitTimeMs | ||
| : 5000; | ||
|
|
||
|
|
||
| // TODO: synchronizer should be a list, but for this is a temporary workaround | ||
| // so that we can pass the contract tests in a more reasonable manner. | ||
| // SDK-1798 | ||
| const adaptedConfigs = { | ||
| ...options.configuration, | ||
| }; | ||
|
|
||
| adaptedConfigs.dataSystem.synchronizers = { | ||
| primary: options.configuration.dataSystem.synchronizers?.[0], | ||
| secondary: options.configuration.dataSystem.synchronizers?.[1], | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shallow copy causes unintended input mutationMedium Severity The shallow copy of |
||
| const client: LDClient = ld.init( | ||
| options.configuration.credential || 'unknown-sdk-key', | ||
| makeSdkConfig(options.configuration, options.tag), | ||
| makeSdkConfig(adaptedConfigs, options.tag), | ||
| ); | ||
| try { | ||
| await client.waitForInitialization({ timeout }); | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing null check causes crash when dataSystem undefined
High Severity
The code accesses
adaptedConfigs.dataSystem.synchronizerswithout checking ifdataSystemexists first. SincedataSystemis an optional property inSdkConfigOptions, this throws a TypeError whenoptions.configuration.dataSystemis undefined. ThemakeSdkConfigfunction properly checksif (options.dataSystem)before accessing it, but this workaround code doesn't perform the same validation, creating an inconsistency that causes runtime crashes.