buildtools icon indicating copy to clipboard operation
buildtools copied to clipboard

buildozer dict_add/dict_set does not allow for colons in keys

Open nacl opened this issue 4 years ago • 3 comments

The current buildozer syntax for dict_add and dict_set requires users to pass in colon-delimited strings do distinguish between keys and values. Unfortunately, at least one use case, the label_keyed_string_dict attribute, is not supported by this scheme -- there is no way to tell buildozer what colon to use for the split -- it always tries to use the first one.

Say you have a rule like this:

foo(
    name = "foo",
)

With an attribute d that is a label_keyed_string_dict. I want to add a value like "//foo/bar:baz": hello-there" to d. The only available buildozer syntax is something like this:

$ buildozer 'dict_add d //foo/bar:baz:hello-there' //:foo

Which results in:

foo(
    name = "foo",
    d = {"//foo/bar": "baz:hello-there"},
)

Which is not desired. Escaping the first colon with \'s does not work either: they end up in the key string.

Potential solutions:

  • Allow for escaping the colons that are not to be used as split parameters
  • Change the input to allow for keys and values to be separate arguments

nacl avatar Jun 11 '21 12:06 nacl

I just ran into the same thing and it broke some targets. It's definitely surprising that quoting works for the value but not for the key.

hybrist avatar Nov 04 '21 22:11 hybrist