[Bug] GovDoc2Poster: basemodel.py ignores DASHSCOPE_API_KEY environment variable and uses hardcoded placeholder instead
Description
GovDoc2Poster loads environment variables via load_dotenv() and instructs users to configure DASHSCOPE_API_KEY, but the environment variable is never read.
In basemodel.py:
load_dotenv()
# Prefer API key from environment for security and flexibility
self.api_key = "your_api"
Additionally, the code logs the following warning:
if not self.api_key:
self.logger.warning(
"DASHSCOPE API key is not set. Set DASHSCOPE_API_KEY env var or update basemodel.py"
)
However, a repository-wide search shows no usage of os.getenv() in the GovDoc2Poster example, meaning the environment variable is never read.
The hardcoded placeholder value is then propagated to downstream OpenAI-based components, including:
NewGovernmentDocumentParser
NewGovernmentPosterPlanner
NewGovernmentPosterEvaluator
As a result, users who configure DASHSCOPE_API_KEY through environment variables cannot have it automatically picked up by the GovDoc2Poster pipeline.
Steps to Reproduce
- Set an environment variable:
$env:DASHSCOPE_API_KEY="test_key_123"
- Verify it is available:
echo $env:DASHSCOPE_API_KEY
Output:
- Search the GovDoc2Poster codebase:
git grep -n "os.getenv" examples/GovDoc2Poster
- Observe that no results are returned and
basemodel.py always assigns:
self.api_key = "your_api"
Expected Behavior
When DASHSCOPE_API_KEY is configured, GovDoc2Poster should automatically read and use it.
Actual Behavior
The environment variable is ignored and the placeholder value "your_api" is propagated to downstream components.
Possible Fix
Read the API key from the environment and validate that a usable value is available:
self.api_key = kwargs.get(
"api_key",
os.getenv("DASHSCOPE_API_KEY", "")
)
if not self.api_key:
raise ValueError(
"API key not found. Set the DASHSCOPE_API_KEY "
"environment variable or pass api_key as a parameter."
)
This would make the implementation consistent with the existing warning message and the intended environment-variable-based configuration workflow.
Suggested Label
kind/bug
[Bug] GovDoc2Poster: basemodel.py ignores DASHSCOPE_API_KEY environment variable and uses hardcoded placeholder instead
Description
GovDoc2Posterloads environment variables viaload_dotenv()and instructs users to configureDASHSCOPE_API_KEY, but the environment variable is never read.In
basemodel.py:Additionally, the code logs the following warning:
However, a repository-wide search shows no usage of
os.getenv()in the GovDoc2Poster example, meaning the environment variable is never read.The hardcoded placeholder value is then propagated to downstream OpenAI-based components, including:
NewGovernmentDocumentParserNewGovernmentPosterPlannerNewGovernmentPosterEvaluatorAs a result, users who configure
DASHSCOPE_API_KEYthrough environment variables cannot have it automatically picked up by the GovDoc2Poster pipeline.Steps to Reproduce
echo $env:DASHSCOPE_API_KEYOutput:
basemodel.pyalways assigns:Expected Behavior
When
DASHSCOPE_API_KEYis configured, GovDoc2Poster should automatically read and use it.Actual Behavior
The environment variable is ignored and the placeholder value
"your_api"is propagated to downstream components.Possible Fix
Read the API key from the environment and validate that a usable value is available:
This would make the implementation consistent with the existing warning message and the intended environment-variable-based configuration workflow.
Suggested Label
kind/bug