-
Notifications
You must be signed in to change notification settings - Fork 325
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
[Bug] DSN is not interpolated at runtime with environment variable #410
Comments
It's reproducible but no time right now to find the cause. Will happily draft 2.1.1 release after we fix this as it's quite fundamental (the Symfony recipe generates this suggested code). |
Unlikely, it only added env support for profile, support for DSN was already there and imho was resolving env during compile time before. |
If anything, I'd suggest to dig into #378, that PR changed how DSN is being resolved. |
Hum yes given #361 (comment) that seems plausible hehe. |
Scrap that, I reproduced it once this afternoon in a project right after upgrading 2.0.6 to 2.1.0, but not since. @B-Galati doesn't cache clearing fix this for you? Perhaps a hard |
@curry684 No it's not fixing the issue. The value of the env variable stays hardcoded in the cache instead of having the env name resolved at runtime. |
I'm sorry but I've just tried reproducing the issue in every possible way, with both phpredis and Predis, in a Symfony 4 project with SncRedisBundle 2.1.0, and it's all just working as it should. This still indicates the only reason I saw it once could've been because of lingering cache. I'm marking this as not reproducible until I can debug a failing case. |
@curry684 thank you for your help. I set up a new SF4 project and I have the same problem : ❯ grep -ri "REDIS_URL" var
// nothing
❯ grep -ri "localhost" var
var/cache/dev/srcDevDebugProjectContainer.xml: <parameter key="router.request_context.host">localhost</parameter>
var/cache/dev/srcDevDebugProjectContainer.xml: <argument>redis://localhost</argument>
var/cache/dev/srcDevDebugProjectContainer.xml: <argument>memcached://localhost</argument>
var/cache/dev/srcDevDebugProjectContainer.xml: <argument>localhost</argument>
var/cache/dev/srcDevDebugProjectContainer.xml: <argument key="host">localhost</argument>
var/cache/dev/ContainerFncx1D4/getSncRedis_DefaultService.php:return $this->services['snc_redis.default'] = new \Predis\Client(new \Predis\Connection\Parameters(array('read_write_timeout' => NULL, 'iterable_multibulk' => false, 'profile' => 'default', 'prefix' => NULL, 'service' => NULL, 'async_connect' => false, 'timeout' => 5, 'persistent' => false, 'exceptions' => true, 'logging' => true, 'alias' => 'default', 'scheme' => 'tcp', 'host' => 'localhost', 'port' => 6379, 'password' => NULL, 'weight' => NULL)), new \Predis\Configuration\Options(array('read_write_timeout' => NULL, 'iterable_multibulk' => false, 'profile' => $a, 'prefix' => NULL, 'service' => NULL, 'async_connect' => false, 'timeout' => 5, 'persistent' => false, 'exceptions' => true, 'connections' => $b)));
var/cache/dev/ContainerFncx1D4/srcDevDebugProjectContainer.php: return $this->privates['router.request_context'] = new \Symfony\Component\Routing\RequestContext('', 'GET', 'localhost', 'http', 80, 443);
var/cache/dev/ContainerFncx1D4/srcDevDebugProjectContainer.php: 'router.request_context.host' => 'localhost', What I am expected, illustrated with doctrine for example is :
|
After a downgrade to 2.0.6 I have the expected result :
|
using |
Yea in the PR it just says
But no more information sadly :-( |
Ok, I can also reproduce the issue from skeleton. Suppose I was looking for the wrong problem by trying it out in a dockerized environment, since that means I'm always implicitly dependent on a container compilation with the correct env variables present. In practice, the current implementation is only an issue on Heroku and similar environments. I think we may just need to rethink the entire DSN parsing thing and ignore all of it until we're making a connection at runtime. That would be a big refactor though, so if @kozlice can chime in he may know how to quickfix it for now. |
@B-Galati Hi, can you copy the exact error message you have (if any)? I was thinking to have the same issue as your, but after a long seek, I've found an other track, related to Symfony 4.1 (dev-master) and the |
@romain-pierre there is no error, the value is just replaced at compiletime instead of at runtime, as should be the case with env variables as it enables the Heroku usecase where the env variable may change between requests. |
FYI, I am working on a fix ;-) |
In that case you likely overlooked that unlike those 2 we 'compile' the DSNs during container compilation, removing the runtime reference. |
Reopening as it's only fixed in master now and I'll have to see if I can merge it back in 2.1. |
Let me know if you need anything |
Merged & resolved conflicts @ https://github.com/snc/SncRedisBundle/commits/2.1 |
Hello,
I just upgraded from 2.0.6 to 2.1.0 and my app broke because the DSN was not updated.
It looks like the issue is similar to #302.
I checked my cache and the value of the config is hard-coded instead of using the env variable.
Here is my config :
Am I missing something ?
In the meantime I moved back to 2.0.6 and everything is back to normal.
Let me know for anything and thanks for your help.
The text was updated successfully, but these errors were encountered: