feat: add environment variable fallback for Langfuse configuration#27
feat: add environment variable fallback for Langfuse configuration#27miadisabelle merged 1 commit intomainfrom
Conversation
- Add simple .env file parser (Python 3.6 compatible, no dependencies) - Support LANGFUSE_SECRET_KEY, LANGFUSE_PUBLIC_KEY, LANGFUSE_HOST, LANGFUSE_AUTH3 - Priority order: .env file → system environment → coaia.json → defaults - Maintains backward compatibility with existing environment variables - Resolves issue #26 Co-authored-by: Guillaume Descoteaux-Isabelle <jgwill@users.noreply.github.com>
|
Claude finished @jgwill's task —— View job Code Review Complete ✅Reviewing PR: feat: add environment variable fallback for Langfuse configuration Todo List:
✅ Positive AspectsExcellent Python 3.6 Compatibility
Clean Implementation
Proper Priority OrderThe implementation correctly follows the documented priority: 🐛 Issues FoundCritical Bug in Logic (coaiamodule.py:148, 154)# Lines 148 and 154 - Logic error
if config["jtaleconf"]["host"] == config["jtaleconf"]["host"] or (not env_vars.get("REDIS_HOST") and not os.getenv("REDIS_HOST")):
if config["jtaleconf"]["password"] == config["jtaleconf"]["password"] or (not env_vars.get("REDIS_PASSWORD") and not os.getenv("REDIS_PASSWORD")):Problem: Fix: Should likely be: if config["jtaleconf"]["host"] == "localhost" or (not env_vars.get("REDIS_HOST") and not os.getenv("REDIS_HOST")):
if config["jtaleconf"]["password"] == "" or (not env_vars.get("REDIS_PASSWORD") and not os.getenv("REDIS_PASSWORD")):Quote Handling Edge Case (coaiamodule.py:67-69)if (value.startswith('"') and value.endswith('"')) or \
(value.startswith("'") and value.endswith("'")):
value = value[1:-1]Problem: This will incorrectly strip quotes from values like Suggested Fix: if (value.startswith('"') and value.endswith('"')) or \
(value.startswith("'") and value.endswith("'")):
value = value[1:-1]Error Handling Could Be More Specific (coaiamodule.py:71-72)except Exception as e:
print(f"Warning: Error loading .env file: {e}")Issue: Catches all exceptions, making debugging difficult. Consider catching specific exceptions like
|
Add environment variable fallback support for coaia.json configuration.
Changes
Resolves
Generated with Claude Code