Skip to content

fix: add CLOUDSMITH_KEYRING_* env var aliases to avoid global impact - #356

Open
cloudsmith-iduffy wants to merge 1 commit into
masterfrom
fix/keyring-env-var-aliases
Open

fix: add CLOUDSMITH_KEYRING_* env var aliases to avoid global impact#356
cloudsmith-iduffy wants to merge 1 commit into
masterfrom
fix/keyring-env-var-aliases

Conversation

@cloudsmith-iduffy

Copy link
Copy Markdown
Contributor

Summary

  • Adds CLOUDSMITH_KEYRING_BACKEND as an alias for PYTHON_KEYRING_BACKEND, and CLOUDSMITH_KEYRING_KEY as an alias for KEYRING_PROPERTY_KEYRING_KEY
  • Aliases only apply when the native env var isn't already set, so existing PYTHON_KEYRING_BACKEND/KEYRING_PROPERTY_KEYRING_KEY usage is unaffected
  • Applied consistently across all three keyring entry points (_get_value, _set_value, _delete_value)

Motivation

Ran into this trying to use cloudsmith-keyring in an existing project via the standalone CLI binary. Setting PYTHON_KEYRING_BACKEND in the environment so the CLI would pick it up also got picked up by unrelated Python tooling in the same environment — uv sync started failing because of it. These aliases let the backend/key be configured for the CLI specifically, without a global env var affecting every other Python process.

Test plan

  • Added unit tests covering: alias sets the var when unset, alias does not override an existing native var, no-op when alias is unset, and that resolved backend properties are applied via set_properties_from_env()
  • pytest cloudsmith_cli/core/tests/test_keyring.py — 42 passed
  • pre-commit hooks (ruff format/check, etc.) pass

🤖 Generated with Claude Code

…bal impact
Setting PYTHON_KEYRING_BACKEND/KEYRING_PROPERTY_KEYRING_KEY globally so the
CLI picks up cloudsmith-keyring also gets picked up by unrelated Python
tooling (e.g. uv sync), breaking it. CLOUDSMITH_KEYRING_BACKEND and
CLOUDSMITH_KEYRING_KEY let these be set for the CLI alone; they only apply
when the native keyring env var isn't already set.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@cloudsmith-iduffy
cloudsmith-iduffy requested a review from a team as a code ownerAugust 14, 2026 21:43
CopilotAI lite review requested due to automatic review settings August 14, 2026 21:43

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds Cloudsmith-specific environment variable aliases for configuring keyring behavior in the CLI process, avoiding the need to set global PYTHON_KEYRING_BACKEND / KEYRING_PROPERTY_* variables that can impact unrelated Python tooling.

Changes:

  • Introduces CLOUDSMITH_KEYRING_BACKENDPYTHON_KEYRING_BACKEND aliasing and CLOUDSMITH_KEYRING_KEYKEYRING_PROPERTY_KEYRING_KEY aliasing in cloudsmith_cli/core/keyring.py.
  • Ensures the resolved keyring backend has set_properties_from_env() applied from the keyring entry points (_get_value, _set_value, _delete_value).
  • Adds unit tests and a changelog entry documenting the new env var behavior and precedence rules.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

FileDescription
cloudsmith_cli/core/keyring.pyAdds env var alias syncing and backend preparation to apply keyring properties consistently.
cloudsmith_cli/core/tests/test_keyring.pyAdds tests covering alias precedence/no-op behavior and verifying backend property application.
CHANGELOG.mdDocuments the new env var aliases and intended usage/precedence.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +50 to +53
@pytest.fixture
def mock_get_keyring():
with patch.object(keyring, "get_keyring") as get_keyring_mock:
yield get_keyring_mock
@cloudsmith-iduffy

Copy link
Copy Markdown
ContributorAuthor

@claude review once

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@cloudsmith-iduffy