Skip to content

Worker CLI: pyworkflow.config.yaml broker silently overrides PYWORKFLOW_CELERY_BROKER env var #556

Description

@LivinTribunal

Severity: P2 — ops footgun: a pyworkflow.config.yaml in cwd silently overrides PYWORKFLOW_CELERY_BROKER, so env-var redirection is ignored.

What happens

Setting PYWORKFLOW_CELERY_BROKER has no effect whenever the worker is started from a directory containing a pyworkflow.config.yaml — the yaml's broker wins with no warning. During isolated testing this nearly pointed a test worker at a production redis: the yaml in examples/celery/durable hard-codes redis://localhost:6379/0 and the env override was silently discarded.

Root cause

cli/commands/worker.py:164-171 loads the cwd yaml (discovery.py:94 resolves cwd/pyworkflow.config.yaml) and merges its celery block; then :196-199:

broker_url = celery_config.get("broker", os.getenv("PYWORKFLOW_CELERY_BROKER", ...))

— the env var is only the fallback default when the yaml key is absent, then the value is passed as an explicit param to create_celery_app (:237-241; celery/app.py:319 is again param or env). Effective precedence is file > env, inverted from the conventional flags > env > file that the CLI docstring implies.

Executed evidence (v0.3.8)

setup worker banner
cwd yaml broker …:6391/0 + env PYWORKFLOW_CELERY_BROKER=…:6392/0 ℹ Broker: redis://localhost:6391/0 (env ignored)
same env, yaml removed ℹ Broker: redis://localhost:6392/0

Suggested fix

Read the env var first (os.getenv("PYWORKFLOW_CELERY_BROKER") or celery_config.get("broker") or default), or at minimum log a warning when a set PYWORKFLOW_* env var is being overridden by a config file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions