From 7a76ecba5050e90e284f9017be230753709134df Mon Sep 17 00:00:00 2001 From: burnettk Date: Tue, 28 May 2024 17:01:09 -0400 Subject: [PATCH] fix typing issues and fix issue i introduced --- .../spiffworkflow_backend/config/default.py | 23 ++++++++++--------- .../models/reference_cache.py | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/config/default.py b/spiffworkflow-backend/src/spiffworkflow_backend/config/default.py index 63d5a3dcb..5accef12e 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/config/default.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/config/default.py @@ -20,17 +20,18 @@ def config_from_env(variable_name: str, *, default: str | bool | int | None = No # using docker secrets - put file contents to env value if variable_name.endswith("_FILE"): value_from_file = default if value_from_env is None else value_from_env - if value_from_file and value_from_file.startswith("/run/secrets"): - # rewrite variable name: remove _FILE - variable_name = variable_name.removesuffix("_FILE") - try: - with open(value_from_file) as file: - value_to_return = file.read().strip() # Read entire content and strip any extra whitespace - except FileNotFoundError: - value_to_return = None # Handle the case where the file does not exist - except Exception as e: - current_app.logger.error(f"Error reading from {value_from_file}: {str(e)}") - value_to_return = None # Handle other potential errors + if value_from_file: + if isinstance(value_from_file, str) and value_from_file.startswith("/run/secrets"): + # rewrite variable name: remove _FILE + variable_name = variable_name.removesuffix("_FILE") + try: + with open(value_from_file) as file: + value_to_return = file.read().strip() # Read entire content and strip any extra whitespace + except FileNotFoundError: + value_to_return = None # Handle the case where the file does not exist + except Exception as e: + current_app.logger.error(f"Error reading from {value_from_file}: {str(e)}") + value_to_return = None # Handle other potential errors if value_from_env is not None: if isinstance(default, bool): diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/reference_cache.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/reference_cache.py index 97e895ad0..b6c0512c6 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/reference_cache.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/reference_cache.py @@ -77,7 +77,7 @@ class ReferenceCacheModel(SpiffworkflowBaseDBModel): file_name: str = db.Column(db.String(255), nullable=False) # relative to SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR - relative_location: int = db.Column(db.String(255), index=True, nullable=False) + relative_location: str = db.Column(db.String(255), index=True, nullable=False) properties: dict | None = db.Column(db.JSON) # has_lanes = db.Column(db.Boolean())