Skip to content

fix: read DASHSCOPE_API_KEY from environment in GovDoc2Poster basemodel#549

Open
Fahmid-Arman wants to merge 1 commit into
kubeedge:mainfrom
Fahmid-Arman:fix-govdoc-api-key
Open

fix: read DASHSCOPE_API_KEY from environment in GovDoc2Poster basemodel#549
Fahmid-Arman wants to merge 1 commit into
kubeedge:mainfrom
Fahmid-Arman:fix-govdoc-api-key

Conversation

@Fahmid-Arman

Copy link
Copy Markdown

What type of PR is this?
/kind bug

What this PR does / why we need it:
The GovDoc2Poster example ignored the DASHSCOPE_API_KEY environment variable, defaulting to the hardcoded "your_api" string. This caused downstream LLM/VLM components to fail authentication silently.

This PR updates basemodel.py to:

  • Read the API key from kwargs or fallback to os.environ.get("DASHSCOPE_API_KEY").
  • Raise an explicit ValueError if the key is missing or set to the placeholder, enforcing a fail-fast mechanism.
  • Remove unreachable legacy warning logs.

Which issue(s) this PR fixes:
Fixes #530

@kubeedge-bot kubeedge-bot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 14, 2026
@kubeedge-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Fahmid-Arman
To complete the pull request process, please assign jaypume after the PR has been reviewed.
You can assign the PR to them by writing /assign @jaypume in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubeedge-bot kubeedge-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 14, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves API key handling in the base model by retrieving the key from kwargs or falling back to the DASHSCOPE_API_KEY environment variable, raising a ValueError if it is missing. Feedback suggests using or chaining instead of kwargs.get default arguments to robustly handle cases where api_key is explicitly passed as None.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread examples/GovDoc2Poster/singletask_learning_bench/testalgorithms/gen/basemodel.py Outdated
Signed-off-by: Fahmid Arman <fahmid.brac@gmail.com>
@Fahmid-Arman

Copy link
Copy Markdown
Author

Feedback addressed:

  • Refactored API key retrieval to use or chaining to properly handle cases where api_key is explicitly passed as None.

/assign @jaypume

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] GovDoc2Poster: basemodel.py ignores DASHSCOPE_API_KEY environment variable and uses hardcoded placeholder instead

3 participants