Script Development / Environment Variable DFF.ENV
Environment variables configured in the left sidebar of the Script editor can be read in Script using their IDs.
API
| Method | Description |
|---|---|
DFF.ENV(key, default=None) |
Reads the environment variable; returns default if it does not exist |
DFF.ENV.get(key, default=None) |
Equivalent to calling DFF.ENV(...) directly |
DFF.ENV.keys() |
Returns the list of IDs of available environment variables |
DFF.ENV.ref(key, default=None) |
Creates a lazy reference for DFF.API parameters that support dynamic values |
| Example | |
|---|---|
1 2 3 | |
When an environment variable is not found, default is returned; if no default is provided, None is returned. Environment variables of type password are automatically decrypted; when type conversion is configured, the converted Python value is returned. Configuration errors may cause type conversion to throw an exception, so you should provide a default value or fallback logic when reading optional variables.
| Example with type fallback | |
|---|---|
1 2 3 4 5 | |
Dynamic Reference
DFF.ENV.ref(...) returns a dynamic reference, not the current environment variable value. The reference is resolved when consuming Func metadata and can be used for the delayed_cron_job, timeout, expires, and queue parameters of DFF.API.
| Example | |
|---|---|
1 2 3 | |
Connection addresses, tokens, passwords, and environment-specific configurations should be stored in environment variables first. Do not hard-code them in Script, and do not output sensitive values via print(...) or Func responses.