Skip to content

Fix environment variable parsing for comma-separated values in CLI #20992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Siddhant-K-code
Copy link
Member

Problem

Environment variables with comma-separated values (e.g., COMPOSE_PROFILES=value1,value2,value3) were displaying the scope pattern (*/*) instead of the actual values when using gp env.

Root cause

The parseArgs function in cmd/env.go had incorrect string splitting logic:

kv := strings.SplitN(arg, "=", 1)

Using a limit of 1 prevents any splitting, so "KEY=value" returns ["KEY=value"] as a single element.

Solution

  • Changed strings.SplitN(arg, "=", 1) to strings.SplitN(arg, "=", 2)
  • Simplified validation logic by removing redundant checks
  • Preserved all existing functionality and error handling

Fixes CLC-1662

@Siddhant-K-code Siddhant-K-code requested a review from a team as a code owner August 2, 2025 08:18
@roboquat roboquat added the size/S label Aug 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants