InvalidConfigurationException with new schema validation

prog
Backer | 1
+
0
-

This is how I configure app with environment vars:

parameters:
	db:
		dsn: ::getenv('APP_DB_DSN')
		user: ::getenv('APP_DB_USER')
        ...

database:
	default:
		dsn: %db.dsn%
		user: %db.user%
        ...

Since new schema validation I am getting Nette\DI\InvalidConfigurationException

The option 'database › default › dsn' expects to be string or Nette\Schema\DynamicParameter, object Nette\DI\Definitions\Statement given.

Any ideas how to solve this use case?

Last edited by prog (2019-04-10 12:41)

xr
Backer | 93
+
0
-

I have just stumbled upon this and wonder myself…

How did you solve this issue?

Mabar
Member | 296
+
0
-

We load env variables into parameters through Configurator. You can use e.g. contributte/bootstrap for that

use Contributte\Bootstrap\ExtraConfigurator;

$configurator = new ExtraConfigurator();
$configurator->addEnvParameters();
David Grudl
Nette Core | 7239
+
0
-

Hmmm, related to https://github.com/…i/issues/221

Probably I'll revert it.

xr
Backer | 93
+
0
-

I filed an issue here as well – was not sure if this thread was stale or not.
https://github.com/…i/issues/228
Thanks for your response. I'll check v 3.0.1 if the issue is present or not.

Mabar
Member | 296
+
+1
-

@DavidGrudl Problem will be probably also with that none of our extensions accepts Statement (except options accepting services), all Contributte extensions expect final values. Can we somehow find out what will final values get from Statement be?

xr
Backer | 93
+
0
-

I checked the contributte “ExtraConfigurator”… It does not solve my case, because prefixing ENV vars is not an option (on servers, renaming them would be a BC break for older projects and duplicationg would bring maintenance hell).

Similarly, I could write a tool that would load variables in similar manner or create DynamicParameters out of desired ENV vars, but this is still sub optimal for something as simple as this.

I'm guessing that something like the following would not work either, would it?

<?php
// neon
parameters:
	system:
		proxy: @envWrapper::getEnvAsDynamicParameter(TRUSTED_PROXIES)

http:
	proxy: %system.proxy%
?>
xr
Backer | 93
+
0
-

FYI: I'm getting the same issue with nette/di 3.0.0, 3.0.1 and 3.0.2.

Mabar
Member | 296
+
0
-

Feel free to copy my implementation then. I am not sure if empty prefix will work, but it should not be hard modify it to not use prefix at all.
https://github.com/…ntHelper.php

David Grudl
Nette Core | 7239
+
+1
-

Fixed

matoni555
Member | 40
+
0
-

I use nette/di v3.0.5 and I still get Nette\DI\InvalidConfigurationException (The option ‘gosms › clientId’ expects to be string, object Nette\DI\Definitions\Statement given.) with this:

gosms:
    clientId: @settings::getGoSmsClientId()
    clientSecret: 123456789

services:
	settings:
		class: Settings

Any suggestion how to solve it?