Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

incompatible_string_join_requires_strings: string.join(list) accepts invalid (non-string) list elements #7802

Copy link
Copy link
Closed
@laurentlb

Description

@laurentlb
Issue body actions

With --incompatible_string_join_requires_strings=false, this code was previously accepted by Bazel:

>> ",".join(["a", 1, None, (2, 3)])
.. 
"a,1,None,(2, 3)"

However the argument of string.join should an iterable of strings. Bazel used to implicitly convert each item to a string (https://github.com/bazelbuild/starlark/blob/master/spec.md#stringjoin).

Since Bazel 0.27, this is an error and the flag --incompatible_string_join_requires_strings is set to true. If your code relies on the old behavior, do instead an explicit conversion to string with str:

- ", ".join(my_list)
+ ", ".join([str(e) for e in my_list])

A temporary workaround is to use --incompatible_string_join_requires_strings=false. This flag will be removed in the future.

Error message

If you see an error message similar to this (with a call to string.join in the stack trace), your code is likely affected by this change:

		" ".join(([python_bin, ctx.path(ctx.attr....))
sequence element must be a string (got 'path'). See https://github.com/bazelbuild/bazel/issues/7802 for information about --incompatible_string_join_requires_strings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2We'll consider working on this in future. (Assignee optional)We'll consider working on this in future. (Assignee optional)incompatible-changeIncompatible/breaking changeIncompatible/breaking change

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.