Skip to content

chore: add option to not throw error on user error in dvc js and react#1040

Closed
jsalaber wants to merge 1 commit into
mainfrom
TSO-177-optional-throw-invalid-client-sdk
Closed

chore: add option to not throw error on user error in dvc js and react#1040
jsalaber wants to merge 1 commit into
mainfrom
TSO-177-optional-throw-invalid-client-sdk

Conversation

@jsalaber

@jsalaber jsalaber commented Mar 25, 2025

Copy link
Copy Markdown
Contributor

Changes

  • added option to js sdk to not throw UserError if the user specifies option

@vercel

vercel Bot commented Mar 25, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
js-sdks-web-elements ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 25, 2025 7:09pm
js-sdks-with-provider ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 25, 2025 7:09pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
js-sdks-next-js-page-router ⬜️ Ignored (Inspect) Mar 25, 2025 7:09pm

Comment thread sdk/js/src/index.ts
optionsArg: DevCycleOptions = {},
): DevCycleClient<Variables, CustomData> {
if (!sdkKey) {
if (!sdkKey && optionsArg?.throwOnError) {

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.

can we change this to have an IF statement inside which will at least this.logger.error instead of failing silently?

Also the throwOnError should default to true as that is our existing behaviour.

Suggested change
if (!sdkKey && optionsArg?.throwOnError) {
if (!sdkKey) {
if (optionsArg?.throwOnError) {
throw new UserError(
'Missing SDK key! Call initialize with a valid SDK key',
)
} else {
this.logger.error('Missing SDK key! Call initialize with a valid SDK key)
}
}

sdkKey = config.envKey
}
if (!sdkKey) {
if (!sdkKey && !options?.throwOnError) {

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.

similar to previous, split this into a nested IF which will log an error if the key is missing but throwOnError is false

@jsalaber jsalaber closed this Mar 25, 2025
jonathannorris added a commit that referenced this pull request Apr 27, 2026
- postcss: added resolution ^8.5.10 to root and e2e app package.json files
  to fix medium vulnerabilities (alerts #1038, #1039, #1040)
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.

2 participants