Skip to content

Commit

Permalink
Fixed: misconfigured API_ENABLED defaults (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
signebedi committed Sep 2, 2024
1 parent a119491 commit 00b95e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libreforms_fastapi/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def validate_mongodb_uri(cls, v):

# These configurations govern over the bifurcation of server and client instances, along with UI_ENABLED above.
# For more on decoupling server and client, see https://github.com/signebedi/libreforms-fastapi/issues/329
API_ENABLED: bool = os.getenv('API_ENABLED:', 'False') == 'True'
API_ENABLED: bool = os.getenv('API_ENABLED:', 'True') == 'True'
REMOTE_API_ADDR: AnyUrl | None = os.getenv('REMOTE_API_ADDR:', None)
REMOTE_API_KEY: str | None = os.getenv('REMOTE_API_KEY:', None)

Expand Down
6 changes: 3 additions & 3 deletions libreforms_fastapi/utils/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ def validate_mongodb_configuration(config):
raise ConfigurationError("MongoDB URI cannot be an empty string ('MONGODB_URI') when MongoDB is enabled ('MONGODB_ENABLED' = True).")

def validate_api_configuration(config):
if config.API_ENABLED:
if not config.API_ENABLED:
if not config.REMOTE_API_ADDR:
raise ConfigurationError("The 'REMOTE_API_ADDR' configuration must be set when 'API_ENABLED' is True. Please check your configuration.")
raise ConfigurationError("The 'REMOTE_API_ADDR' configuration must be set when 'API_ENABLED' is False. Please check your configuration.")
if not config.REMOTE_API_KEY:
raise ConfigurationError("The 'REMOTE_API_KEY' configuration must be set when 'API_ENABLED' is True. Please check your configuration.")
raise ConfigurationError("The 'REMOTE_API_KEY' configuration must be set when 'API_ENABLED' is False. Please check your configuration.")

# Main function to check all configurations
def check_configuration_assumptions(config):
Expand Down

0 comments on commit 00b95e0

Please sign in to comment.