fix(utils): Fail silently if the provided Dsn is invalid#8121
Merged
Conversation
Contributor
size-limit report 📦
|
b419764 to
c3043de
Compare
Lms24
commented
May 16, 2023
| }, | ||
| ): string { | ||
| const dsn = makeDsn(dsnLike); | ||
| if (!dsn) { |
Member
Author
There was a problem hiding this comment.
This should just return an empty script tag instead of throwing, causing the dialog not to be fetched (which is fine IMO)
a991580 to
de3e675
Compare
Lms24
commented
May 16, 2023
| throw new SentryError(`Invalid Sentry Dsn: ${str}`); | ||
| // This should be logged to the console | ||
| // eslint-disable-next-line no-console | ||
| console.error(`Invalid Sentry Dsn: ${str}`); |
Member
Author
There was a problem hiding this comment.
I opted to log this as a console error so that this error is easier to spot. More fine-grained validation is still only logged if debug is set
lforst
approved these changes
May 17, 2023
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.
As discussed, we don't want to hard-throw if the SDK gets an invalid DSN. This PR fixes that by allowing
makeDsnanddsnFromStringto returnundefined, which we do if the Dsn is invalid. This is a breaking change for the utils package but since it's utils we're fine with that.(The alternative, try-catching the respective function calls didn't seem much nicer to me, especially considering that we rarely use throwing and try/catching for control flow in the SDK).
This required changes in more places, since we don't only work with raw DSNs in the BaseClient but also in
tunnelRouteoptionmakeMultiplexedTransportwhere I opted to resort to the fallback URL if an invalid URL is returned by the user matchercloses #8110