"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(api): scan quoted dotenv values before stripping hash comments
santhreald84c00f7781e
diff --git a/agent/src/api/helpers.py b/agent/src/api/helpers.pyindex 0cad87b86..24dd29dce 100644--- a/agent/src/api/helpers.py+++ b/agent/src/api/helpers.py@@ -133,13 +133,19 @@ def _ensure_agent_env_file(path: Path | None = None) -> Path:def _strip_env_value(value: str) -> str:"""Remove basic dotenv quotes and inline comments."""value = value.strip()- # Fully quote-wrapped: keep interior `#` (do not treat as comment).- if len(value) >= 2 and value[0] == value[-1] and value[0] in {"'", '"'}:- return value[1:-1].strip()+ if value[:1] in {"'", '"'}:+ q = value[0]+ i = 1+ while i < len(value):+ if value[i] == "\\" and i + 1 < len(value):+ i += 2+ continue+ if value[i] == q:+ return value[1:i].strip()+ i += 1+ return valueif " #" in value:value = value.split(" #", 1)[0].rstrip()- if len(value) >= 2 and value[0] == value[-1] and value[0] in {"'", '"'}:- value = value[1:-1]return value.strip()diff --git a/agent/tests/test_api_infrastructure.py b/agent/tests/test_api_infrastructure.pyindex 85a68ecb0..45f4d2400 100644--- a/agent/tests/test_api_infrastructure.py+++ b/agent/tests/test_api_infrastructure.py@@ -266,6 +266,8 @@ def test_strip_env_value_quoted_then_inline_comment():"""Trailing comments after a closed quote must still be stripped."""assert helpers._strip_env_value('"secret" # comment') == "secret"assert helpers._strip_env_value("'secret' # comment") == "secret"+ assert helpers._strip_env_value('"a # b" # outer') == "a # b"+ assert helpers._strip_env_value("'a # b' # outer") == "a # b"def test_read_write_env_quoted_hash_roundtrip(tmp_path):