Skip to content

Fix Claude autolog to prioritize settings.json over OS environment variables#20376

Merged
B-Step62 merged 1 commit intomlflow:masterfrom
alkispoly-db:claude-autolog-bug
Jan 27, 2026
Merged

Fix Claude autolog to prioritize settings.json over OS environment variables#20376
B-Step62 merged 1 commit intomlflow:masterfrom
alkispoly-db:claude-autolog-bug

Conversation

@alkispoly-db
Copy link
Collaborator

Related Issues/PRs

#xxx

What changes are proposed in this pull request?

The get_env_var() function in mlflow/claude_code/config.py previously checked OS environment variables first and only fell back to settings.json. This caused project-specific configuration to be overridden by global environment variables (e.g., MLFLOW_EXPERIMENT_ID from a different project).

This PR inverts the priority order so that .claude/settings.json values take precedence over OS environment variables:

  1. First check .claude/settings.json (project-specific config)
  2. Fall back to OS environment variables (global/inherited config)
  3. Fall back to default value

How is this PR tested?

  • Existing unit/integration tests
  • New unit/integration tests

New tests added:

  • test_get_env_var_settings_takes_precedence_over_os_env - verifies settings.json takes priority
  • test_get_env_var_falls_back_to_os_env_when_not_in_settings - verifies fallback behavior

Does this PR require documentation update?

  • No. You can skip the rest of this section.

Release Notes

Is this a user-facing change?

  • Yes. Give a description of this change to be included in the release notes for MLflow users.

Claude Code autolog now correctly prioritizes project-specific configuration in .claude/settings.json over OS environment variables, preventing global environment settings from overriding project-specific experiment IDs and tracking URIs.

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionality

How should the PR be classified in the release notes? Choose one:

  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes

Should this PR be included in the next patch release?

  • Yes (this PR will be cherry-picked and included in the next patch release)
  • No (this PR will be included in the next minor release)

…riables

Project-specific configuration in .claude/settings.json should take
precedence over global OS environment variables. This ensures that
MLFLOW_EXPERIMENT_ID set in the project config is not overridden by
values inherited from the shell environment.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Alkis Polyzotis <alkis.polyzotis@databricks.com>
@github-actions
Copy link
Contributor

🛠 DevTools 🛠

Install mlflow from this PR

# mlflow
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/20376/merge
# mlflow-skinny
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/20376/merge#subdirectory=libs/skinny

For Databricks, use the following command:

%sh curl -LsSf https://raw.githubusercontent.com/mlflow/mlflow/HEAD/dev/install-skinny.sh | sh -s pull/20376/merge

@github-actions github-actions bot added area/tracing MLflow Tracing and its integrations rn/bug-fix Mention under Bug Fixes in Changelogs. v3.9.0 labels Jan 27, 2026
@github-actions
Copy link
Contributor

Documentation preview for 4f846a1 is available at:

More info
  • Ignore this comment if this PR does not change the documentation.
  • The preview is updated when a new commit is pushed to this PR.
  • This comment was created by this workflow run.
  • The documentation was built by this workflow run.

Copy link
Collaborator

@smoorjani smoorjani left a comment

Choose a reason for hiding this comment

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

LGTM! Adding Avesh/Yuki for maintainer review

@B-Step62 B-Step62 enabled auto-merge January 27, 2026 23:21
@B-Step62 B-Step62 added this pull request to the merge queue Jan 27, 2026
Merged via the queue into mlflow:master with commit 01a995a Jan 27, 2026
52 of 56 checks passed
harupy pushed a commit to harupy/mlflow that referenced this pull request Jan 28, 2026
…riables (mlflow#20376)

Signed-off-by: Alkis Polyzotis <alkis.polyzotis@databricks.com>
Co-authored-by: Claude <noreply@anthropic.com>
harupy pushed a commit to harupy/mlflow that referenced this pull request Jan 28, 2026
…riables (mlflow#20376)

Signed-off-by: Alkis Polyzotis <alkis.polyzotis@databricks.com>
Co-authored-by: Claude <noreply@anthropic.com>
harupy pushed a commit that referenced this pull request Jan 28, 2026
…riables (#20376)

Signed-off-by: Alkis Polyzotis <alkis.polyzotis@databricks.com>
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tracing MLflow Tracing and its integrations rn/bug-fix Mention under Bug Fixes in Changelogs. v3.9.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants