getredash/redash

Environment variable configuration should take precedence over database settings

Open

#5,626 opened on Oct 18, 2021

View on GitHub
 (0 comments) (3 reactions) (0 assignees)Python (4,236 forks)batch import
Backendhelp wanted

Repository metrics

Stars
 (24,845 stars)
PR merge metrics
 (Avg merge 6d 17h) (2 merged PRs in 30d)

Description

Right now, if settings are introduced that are configurable by environment variables, they will be ignored in favour of configured database settings.

This is because the organization model prefers to get its settings from the database (short circuit): https://github.com/getredash/redash/blob/143d22db04a9058966b8c7d678b06f228b937326/redash/models/organizations.py#L69

and there is no mechanism to synchronize database settings with detected environment variables, even if they are initially loaded via https://github.com/getredash/redash/blob/master/redash/settings/organization.py .

I would like to suggest that environment variables, when present, should be preferred over prior DB stored settings, as they should always be assumed to have been most recently provided as the desired configuration versus anything that may have been previously configured and persisted.

This matches the typical behaviour of many other software, where command-line arguments or envars always take precedence over local files.

Contributor guide