iflytek/astron-agent · error · ValueError
Redis address is not set in environment variables
Error message
Redis address is not set in environment variables
What it means
_get_or_create_redis_service needs a Redis address to construct a RedisService for migration support. It reads REDIS_CLUSTER_ADDR_KEY first, falling back to REDIS_ADDR_KEY, and also reads REDIS_PASSWORD_KEY. If neither address variable is set (or empty) it raises ValueError 'Redis address is not set in environment variables'.
Solutions
- Set REDIS_CLUSTER_ADDR (preferred) or REDIS_ADDR in the environment before running the migration
- Verify the deployment manifest / compose file exports the exact env key names expected by const.py
- Check for renamed keys after upgrades and update configs to the current const names
- Optionally set REDIS_PASSWORD too if the Redis instance requires auth
Example fix
// before (.env) # no redis config // after (.env) REDIS_CLUSTER_ADDR=127.0.0.1:6379 REDIS_PASSWORD=secret
Defensive patterns
Strategy: validation
Validate before calling
import os
def has_redis_addr() -> bool:
return bool(os.getenv("REDIS_CLUSTER_ADDR") or os.getenv("REDIS_ADDR")) Try / catch
try:
run_database_migration()
except ValueError as e:
if "Redis address" in str(e):
sys.exit(f"Config error: {e}")
raise Prevention
- Set REDIS_CLUSTER_ADDR (or REDIS_ADDR) in every environment that runs migrations
- Mirror the exact const.py key names in deployment manifests to avoid typos
- Add a pre-flight env validation step to startup scripts and CI
- Include REDIS_PASSWORD when auth is enabled to avoid follow-on auth failures
When it happens
Trigger: Running run_database_migration in an environment where neither the cluster-address nor the standalone-address Redis env var is defined, regardless of whether the password is set.
Common situations: Deploying without Redis config in .env/Helm values; REDIS_CLUSTER_ADDR removed in favor of REDIS_ADDR (or vice versa) after an upgrade; typo'd env var names in the deployment manifest; running migrations locally without the infrastructure env file.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- Missing required MySQL environment variables for migration
- WECHAT_VERIFY_TICKET_MISSING
- RUN_MCP_PLUGIN_URL is not set
- LIST_MCP_PLUGIN_URL is not set
- RAGFLOW_BASE_URL not configured in environment variables
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/5656436ce127c30a.
Report an issue: GitHub.
Appendix: source
Thrown at core/plugin/link/extensions/database_migration.py:91
config = Config(str(alembic_ini))
config.set_main_option("script_location", str(alembic_dir))
return config
def _get_or_create_redis_service() -> RedisService:
"""Get or create Redis service instance."""
redis_service = get_redis_engine()
if redis_service is not None:
logging.info("redis_service is successfully got from get_redis_engine()")
return redis_service
redis_addr = os.getenv(const.REDIS_CLUSTER_ADDR_KEY) or os.getenv(
const.REDIS_ADDR_KEY
)
redis_password = os.getenv(const.REDIS_PASSWORD_KEY)
if not redis_addr:
logging.error("Redis address is not set in environment variables")
raise ValueError("Redis address is not set in environment variables")
return RedisService(cluster_addr=redis_addr, password=redis_password)
def _handle_migration_error(config: Config, error: OperationalError) -> None:
"""Handle migration operational errors."""
db_error_code = getattr(error.orig, "args", [None])[0]
if db_error_code in (
MYSQL_ERROR_SELECT_DENIED,
MYSQL_ERROR_ACCESS_DENIED,
MYSQL_ERROR_EXECUTE_DENIED,
):
logging.warning(
f"Skip database migration due to insufficient permissions: {error}"
)
return
View on GitHub (pinned to 5e758547a8)