Skip to content

fix: MLflow env vars overwritten in settings.json due to race condition #153

@datasciencemonkey

Description

@datasciencemonkey

Bug

setup_mlflow.py merges MLflow env vars (MLFLOW_TRACKING_URI, MLFLOW_EXPERIMENT_NAME, etc.) into ~/.claude/settings.json, but they get silently wiped by two separate code paths:

1. _configure_all_cli_auth() overwrites settings.json from scratch

app.py:294-309 creates a fresh dict and writes it, nuking any existing content:

settings = {
    "env": {
        "ANTHROPIC_MODEL": ...,
        "ANTHROPIC_AUTH_TOKEN": token,
        ...
    }
}
with open(settings_path, "w") as f:
    json.dump(settings, f, indent=2)

This runs in configure_pat() before run_setup() kicks off, so it overwrites any MLflow vars from a prior setup.

2. setup_claude.py and setup_mlflow.py run in parallel

Both are in the parallel_steps list in run_setup(). If setup_claude.py writes settings.json, it can clobber what setup_mlflow.py just merged — race condition on the same file.

Fix

  1. _configure_all_cli_auth() should read-merge-write instead of overwriting settings.json
  2. setup_mlflow.py should run after setup_claude.py (sequentially), not in parallel

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions