Skip to content

Commit ef39822

Browse files
author
Jah-Wilson Teeba
committed
Fixed Bandit risks
1 parent 26cad99 commit ef39822

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/chroma_knowledge_search/backend/app/config.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,12 @@ def load_config():
5454
from dotenv import load_dotenv
5555

5656
load_dotenv()
57-
except Exception:
58-
pass # .env file may not exist in CI
57+
except ImportError:
58+
# dotenv not available, skip loading
59+
pass
60+
except FileNotFoundError:
61+
# .env file may not exist in CI
62+
pass
5963

6064

6165
def get_allow_origins():

src/chroma_knowledge_search/backend/app/db.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ def get_engine():
1616
from chroma_knowledge_search.backend.app.config import load_config
1717

1818
load_config()
19-
except Exception:
20-
pass # Config loading may fail in tests
19+
except (ImportError, FileNotFoundError):
20+
# Config loading may fail in tests or when files don't exist
21+
pass
2122

2223
db_url = os.getenv("DB_URL", "sqlite+aiosqlite:///:memory:")
2324
_engine = create_async_engine(db_url, echo=False, future=True)

src/chroma_knowledge_search/backend/app/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,8 @@ async def health():
5757

5858
if __name__ == "__main__":
5959
import uvicorn
60+
import os
6061

61-
uvicorn.run(app, host="0.0.0.0", port=10000)
62+
host = os.getenv("HOST", "127.0.0.1")
63+
port = int(os.getenv("PORT", "8000"))
64+
uvicorn.run(app, host=host, port=port)

0 commit comments

Comments
 (0)