RuntimeError: Working outside of application context when loading instance config after upgrade
0 reputation · 11 Apr 2024, 01:33 UTC
The goal is to confirm that after a failed Flask upgrade and subsequent downgrade, instance‑specific configuration files are loaded correctly when using the application factory pattern.
Currently the instance_relative_config flag defaults to False, which can cause confusion about where Flask expects to find the instance folder. This uncertainty interacts with the factory pattern because the app instance is created inside create_app, and developers may rely on the default behavior to locate config files without explicitly setting the flag.
Constraints include maintaining compatibility with existing extensions that may assume the current default, avoiding reintroduction of security vulnerabilities from older Flask versions, and ensuring that config loading works consistently across major releases.
What should the default value of instance_relative_config be to minimize confusion for factory‑based applications?
How does the current default affect applications that have not explicitly set the flag when upgrading or downgrading Flask?
Are there recommended practices for verifying instance config loading behavior across Flask versions without manual inspection?