Skip to content

Conversation

rajeshkanaka
Copy link
Contributor

…bles

  • Filter out None and empty string values from env_vars dictionary
  • Add logging for skipped environment variables
  • Maintain backward compatibility with empty strings in .env files
  • Fixes TypeError when BQML_RAG_CORPUS_NAME and CODE_INTERPRETER_EXTENSION_NAME are empty

Fixes #192

rajeshkanaka and others added 8 commits July 22, 2025 17:38
…bles

- Filter out None and empty string values from env_vars dictionary
- Add logging for skipped environment variables
- Maintain backward compatibility with empty strings in .env files
- Fixes TypeError when BQML_RAG_CORPUS_NAME and CODE_INTERPRETER_EXTENSION_NAME are empty

Fixes google#192
- Default ROOT_AGENT_MODEL to gemini-2.5-flash
- Filter empty env vars with aggregated logging before deploy
- Raise UsageError for missing flags and tidy agent deletion message
Removed 'NL2SQL_METHOD' from the list of environment variables.
@Copilot Copilot AI review requested due to automatic review settings September 27, 2025 11:42
Copy link

google-cla bot commented Sep 27, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes deployment failures for data-science agents caused by None and empty environment variables. The main issue was a TypeError occurring when BQML_RAG_CORPUS_NAME and CODE_INTERPRETER_EXTENSION_NAME environment variables were empty.

  • Filter out None, empty, and whitespace-only values from environment variables before deployment
  • Replace print statements with proper app.UsageError exceptions for better error handling
  • Add comprehensive logging for environment variable processing and skipped values

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
python/agents/data-science/deployment/deploy.py Refactored environment variable handling with filtering logic, improved error handling with exceptions, and added detailed logging
python/agents/data-science/data_science/agent.py Added default fallback value for ROOT_AGENT_MODEL environment variable

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +207 to +236
for key in env_var_keys:
value = os.getenv(key)
# Only add to env_vars if the value has actual content (not None, empty, or whitespace-only)
if value and value.strip():
env_vars[key] = value
logger.info("Including environment variable: %s", key)
else:
logger.info("Skipping empty/None/whitespace-only environment variable: %s (value: %s)", key, repr(value))

logger.info("Environment variables to be passed to agent: %s", list(env_vars.keys()))

skipped_vars: list[str] = []
for key in env_var_keys:
value = os.getenv(key)
# Only add to env_vars if the value is not None/empty and not just
# whitespace
if value and value.strip():
env_vars[key] = value
else:
skipped_vars.append(key)

if skipped_vars:
logger.info(
"Skipped empty/None/whitespace environment variables: %s",
skipped_vars,
)

logger.info(
"Environment variables to be passed to agent: %s", list(env_vars.keys())
)
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

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

The environment variable processing logic is duplicated. The first loop (lines 207-214) and second loop (lines 219-226) perform identical filtering. Remove the duplication by keeping only one loop and consolidating the logging.

Copilot uses AI. Check for mistakes.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Rajesh Pandhare <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deployment fails with None value in .env for BQML_RAG_CORPUS_NAME and CODE_INTERPRETER_EXTENSION_NAME

2 participants