Skip to content

fix(cli): keep commas in --attribute values - #1004

Closed
RaphaelFakhri wants to merge 1 commit into
livekit:mainfrom
RaphaelFakhri:fix/attribute-flag-comma
Closed

RaphaelFakhri wants to merge 1 commit into
livekit:mainfrom
RaphaelFakhri:fix/attribute-flag-comma

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Fixes #1003

Summary

--attribute KEY=VALUE is a string slice flag. urfave/cli splits slice flag values on commas unless the command sets DisableSliceFlagSeparator. The commands below did not set it, so a value that contains a comma is split into separate pairs:

lk token create --attribute tags=a,b

parseKeyValuePairs then receives tags=a and b, and the result is {"tags": "a", "": "b"}. The value is truncated and a bogus attribute with an empty key is added.

This change sets DisableSliceFlagSeparator on the commands that read --attribute, following the existing handling of secrets and agent attributes:

  • lk token create and the deprecated lk create-token
  • lk room join
  • lk perf agent-load-test

Repeat the flag to pass more than one attribute.

These commands also accept comma-separated values for --allow-source (for example camera,microphone). Because the separator is now disabled, lk token create splits those values itself in parseAllowSources.

Testing

  • Adds TestAttributeFlagKeepsCommasInValues, which finds every command in the token, room, and perf trees that defines --attribute and parses --attribute tags=a,b --attribute mode=x with that command's flags and separator setting.
  • The test fails for all four commands on main and passes with this change.
  • Adds TestParseAllowSources for the comma-separated --allow-source values.
  • go test ./cmd/lk passes.

@CLAassistant

CLAassistant commented Sep 29, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--attribute values are split on commas

2 participants