Skip to content

fix(no-ticket): write launcher settings as the text each option accepts - #551

Closed
cloudsmith-iduffy wants to merge 1 commit into
iduffy/launcher-install-time-settingsfrom
iduffy/fix-launcher-non-string-settings
Closed

cloudsmith-iduffy wants to merge 1 commit into
iduffy/launcher-install-time-settingsfrom
iduffy/fix-launcher-non-string-settings

Conversation

@cloudsmith-iduffy

Copy link
Copy Markdown
Collaborator

Description

cloudsmith credential-helper install crashes when a launcher keeps a setting whose value is not text (Sentry CLOUDSMITH-CLI-1F). The install keeps each CLOUDSMITH_* option that comes from a flag or the environment, but it only turned bool values into text. The --color / CLOUDSMITH_COLOR option parses to a ColorMode enum, and that enum went straight into shlex.quote.

Before (with a helper that keeps install-time settings):

$ CLOUDSMITH_COLOR=never cloudsmith credential-helper install docker --no-discover
Error: TypeError: expected string object, got 'ColorMode'

str() is not a fix on its own. It gives ColorMode.NEVER, and the helper then refuses to start:

Error: Invalid value for '--color': 'ColorMode.NEVER' is not one of 'auto', 'always', 'never'.

After:

$ CLOUDSMITH_COLOR=NEVER cloudsmith credential-helper install docker --no-discover
$ cat ~/.cloudsmith/bin/docker-credential-cloudsmith
#!/bin/sh
export CLOUDSMITH_NO_KEYRING=1
export CLOUDSMITH_COLOR=never
exec cloudsmith credential-helper docker "$@"

The changes:

  • Each kept value now becomes the text that its option accepts. A click.Choice value goes through Choice.normalize_choice, so an enum becomes its name in the case the option takes (never). An int or float becomes str(). A bool keeps its lower-case form.
  • A list of values (multiple=True or nargs) is not kept, because one launcher variable holds one value. No current CLOUDSMITH_* option on install takes a list.
  • The launcher writer refuses a value that is not a string. The message names the variable, so a future bug does not show up as a TypeError deep in shlex.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring
  • Other (please describe)

Additional Notes

This PR stacks on #511 and fixes code that has not been released, so it has no CHANGELOG entry.

#512 already leaves color out of the kept settings. With that branch plus this fix, and color put back in the kept list, the install writes CLOUDSMITH_COLOR=never. The launcher then runs the helper, which accepts the value and goes on to the credential lookup. With the old str() form, the helper exits with the usage error above.

🤖 Generated with Claude Code

The install command kept the parsed value of each CLOUDSMITH_* option.
An enum value such as the --color choice went to shlex.quote and the
install stopped with a TypeError. Now each value becomes the text that
its option accepts. A list of values is not kept. The launcher writer
refuses a value that is not a string, with a clear message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 24, 2026 17:53

Copilot AI 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.

🟢 Approval recommended

The focused fix addresses the reported failure with regression coverage and no identified blocking issues.

No open issues 🎉

What changed in this PR

Fixes serialization of install-time settings in credential-helper launchers, preventing crashes from non-text values while preserving text accepted by each CLI option.

Changes:

  • Normalize choices and scalar values to text; skip multi-value settings.
  • Reject non-string launcher values with an error naming the variable.
  • Add regression coverage for enum choices, integers, skipped multi-values, and launcher validation.
File Description
cloudsmith_cli/​credential_helpers/​launchers.py Validate that launcher environment values are strings.
cloudsmith_cli/​cli/​tests/​commands/​test_credential_helper_install.py Cover setting serialization and non-string rejection.
cloudsmith_cli/​cli/​commands/​credential_helper/​manage.py Convert retained settings to option-compatible text.

Review effort: Balanced

@cloudsmith-iduffy

Copy link
Copy Markdown
Collaborator Author

I will handle this as part of #512

@cloudsmith-iduffy

Copy link
Copy Markdown
Collaborator Author

Closing as a duplicate of #512. #512 never keeps color or force_color_env, and every other setting it keeps is text, a path (Click returns str) or a bool, which it already turns into lower-case text. So no enum, number or tuple can reach the launcher writer, and #512 needs no change.

Sign up for free to 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