-
-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix SENTRY_DSN handling with nullable values #522
Fix SENTRY_DSN handling with nullable values #522
Conversation
Maybe you should take a look at our official Laravel integration? Also, env variables are always strings, you shouldn't set them at all to obtain a null/false value. |
Already using https://github.com/getsentry/sentry-laravel.
I find it confusing that in Again, maybe you're right but maybe If you don't find this fit, then ok. But i think we can agree that "null" and "false" could be used as a disabler and there is no way they could be confused for a proper dsn |
Not saying it's a good idea but maybe we can take hint from Laravel on reading "environment" variables. I do think setting it to We could check for these values for example, what do you think @Jean85? |
I agree with taking inspiration from that piece of Laravel code; but I would like to have tests on this feature too, then we can merge it. |
@stayallive Where would you like that piece of code added ? I could try to add it, or if you're more comfortable doing it, i won't mind. |
…y array \nAdded tests to test the new functionality\n Updated bine\sentry to fail if parseDSN returns empty
@stayallive @Jean85 |
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.
This looks fine for me, @Jean85 something similair should also be adapted for 2.0, but for 1.x I think this is fine.
Thanks @salexi, I took the liberty of refactoring your tests with a dataprovider. @stayallive that's why I requested tests, I intend to merge master into 2.0 before releasing, and take there all the new stuff that we merged on master after branching for the new release. |
Great, thanks 👍 |
FYI: 1.8.2 has been released with this PR in it. Thanks! |
I will assume that when reading options for
Raven\Client
you want$_SERVER
variable to overwrite any settings from config for example.In laravel's case, we have a small issue. When reading the
.env
file laravel puts anything it finds there in$_SERVER
asstrings
If i write a proper
SENTRY_DSN
in.env
file or if i leave it empty, everything is fine. But if i writeSENTRY_DSN=false
orSENTRY_DSN=null
in the .env file, my app will crash.$options
has dsn with a correct value ofnull
orfalse
, however it's overwritten by$_SERVER['SENTRY_DSN']
which is"false"
or"null"
(as strings). This causes theRaven_Client::parseDSN($dsn)
; to failIn this PR before assigning
$dsn = @$_SERVER['SENTRY_DSN]
i check if$_SERVER['SENTRY_DSN]
contains"false"
or"null"
and if so, i assign$dsn = null
.This makes laravel not crash anymore.