Skip to content
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

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

Closed
laurentlb opened this issue Mar 21, 2019 · 4 comments
Labels
incompatible-change Incompatible/breaking change P2 We'll consider working on this in future. (Assignee optional)

Comments

@laurentlb
Copy link
Contributor

laurentlb commented Mar 21, 2019

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.
@laurentlb laurentlb added P2 We'll consider working on this in future. (Assignee optional) team-Starlark incompatible-change Incompatible/breaking change labels Mar 21, 2019
bazel-io pushed a commit that referenced this issue Mar 28, 2019
#7802

RELNOTES:
  A new flag `--incompatible_string_join_requires_strings` is introduced. The sequence argument of `string.join` must contain only string elements.
PiperOrigin-RevId: 240775005
@laurentlb laurentlb changed the title string.join(list) accepts invalid (non-string) list elements incompatible_string_join_requires_strings: string.join(list) accepts invalid (non-string) list elements Mar 28, 2019
@dkelmer
Copy link
Contributor

dkelmer commented Apr 3, 2019

@laurentlb, is the migration window 1 release? I added the breaking-change-0.26 label if it is, but if it's not, that needs to be updated

copybara-github pushed a commit to google/copybara that referenced this issue May 24, 2019
The default will change in Starlark interpreter. This line allows Copybara
to do the migration separately.

See bazelbuild/bazel#7802 for details

PiperOrigin-RevId: 249818361
Change-Id: I45b316121083ee5c5895230858c584cb4b2b74f6
lucamilanesio pushed a commit to GerritCodeReview/gerrit that referenced this issue Jun 6, 2019
Bazel 0.27 is going to flip incompatible Starlark flag:
--incompatible_string_join_requires_strings, see: [1] for
more details.

[1] bazelbuild/bazel#7802

Bug: Issue 10930
Change-Id: I058ba29a006e0af665830f3408e82cef4cbb1660
lucamilanesio pushed a commit to GerritCodeReview/gerrit that referenced this issue Jun 9, 2019
Bazel 0.27 is going to flip incompatible Starlark flag:
--incompatible_string_join_requires_strings, see: [1] for
more details.

[1] bazelbuild/bazel#7802

Bug: Issue 10998
Change-Id: Ibd6c77af8ed1ce5dc86ce88996003f7cf695aa08
irengrig pushed a commit to irengrig/bazel that referenced this issue Jun 18, 2019
Fixes bazelbuild#7802

RELNOTES: --incompatible_string_join_requires_strings is now enabled by default
PiperOrigin-RevId: 250159837
lucamilanesio pushed a commit to GerritCodeReview/bazlets that referenced this issue Jul 2, 2019
Bazel 0.27 flipped incompatible Starlark flag:
--incompatible_string_join_requires_strings, see: [1] for
more details.

[1] bazelbuild/bazel#7802

Bug: Issue 10998
Change-Id: I7972d15d914c11689f1808df56a0eb79e0075e73
@davido
Copy link
Contributor

davido commented Jul 4, 2019

@laurentlb Is this expected that we see "Internal error thrown during build."?

$ bazel build :polygerrit 
INFO: Invocation ID: 550150d9-ac5f-401e-b9aa-d22e9662b4f3
INFO: Call stack for the definition of repository 'polymer' which is a bower_archive (rule definition at /home/davido/projects/gerrit2/tools/bzl/js.bzl:121:17):
 - /home/davido/projects/gerrit2/WORKSPACE:1092:1
ERROR: An error occurred during the fetch of repository 'polymer':
   Traceback (most recent call last):
	File "/home/davido/projects/gerrit2/tools/bzl/js.bzl", line 83
		fail(("failed %s: %s" % (" ".join(cmd...)))
	File "/home/davido/projects/gerrit2/tools/bzl/js.bzl", line 83, in fail
		" ".join(cmd)
sequence element must be a string (got 'path'). See https://github.com/bazelbuild/bazel/issues/7802 for information about --incompatible_string_join_requires_strings.
Internal error thrown during build. Printing stack trace: java.util.UnknownFormatConversionException: Conversion = ' '
	at java.base/java.util.Formatter.checkText(Formatter.java:2732)
	at java.base/java.util.Formatter.parse(Formatter.java:2718)
	at java.base/java.util.Formatter.format(Formatter.java:2655)
	at java.base/java.util.Formatter.format(Formatter.java:2609)
	at java.base/java.lang.String.format(String.java:2897)
	at com.google.devtools.build.lib.skyframe.SkyframeDependencyResolver.getTargets(SkyframeDependencyResolver.java:145)
	at com.google.devtools.build.lib.analysis.DependencyResolver.dependentNodeMap(DependencyResolver.java:274)
	at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.computeDependencies(ConfiguredTargetFunction.java:562)
	at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.compute(ConfiguredTargetFunction.java:317)
	at com.google.devtools.build.skyframe.AbstractExceptionalParallelEvaluator.bubbleErrorUp(AbstractExceptionalParallelEvaluator.java:495)
	at com.google.devtools.build.skyframe.ParallelEvaluator.bubbleErrorUpExceptionally(ParallelEvaluator.java:77)
	at com.google.devtools.build.skyframe.AbstractExceptionalParallelEvaluator.waitForCompletionAndConstructResult(AbstractExceptionalParallelEvaluator.java:282)
	at com.google.devtools.build.skyframe.AbstractExceptionalParallelEvaluator.doMutatingEvaluation(AbstractExceptionalParallelEvaluator.java:265)
	at com.google.devtools.build.skyframe.AbstractExceptionalParallelEvaluator.evalExceptionally(AbstractExceptionalParallelEvaluator.java:201)
	at com.google.devtools.build.skyframe.ParallelEvaluator.eval(ParallelEvaluator.java:70)
	at com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator.evaluate(InMemoryMemoizingEvaluator.java:205)
	at com.google.devtools.build.skyframe.SequentialBuildDriver.evaluate(SequentialBuildDriver.java:38)
	at com.google.devtools.build.lib.skyframe.SkyframeExecutor.configureTargets(SkyframeExecutor.java:2381)
	at com.google.devtools.build.lib.skyframe.SkyframeBuildView.configureTargets(SkyframeBuildView.java:373)
	at com.google.devtools.build.lib.analysis.BuildView.update(BuildView.java:399)
	at com.google.devtools.build.lib.buildtool.AnalysisPhaseRunner.runAnalysisPhase(AnalysisPhaseRunner.java:198)
	at com.google.devtools.build.lib.buildtool.AnalysisPhaseRunner.execute(AnalysisPhaseRunner.java:110)
	at com.google.devtools.build.lib.buildtool.BuildTool.buildTargets(BuildTool.java:141)
	at com.google.devtools.build.lib.buildtool.BuildTool.processRequest(BuildTool.java:268)
	at com.google.devtools.build.lib.runtime.commands.BuildCommand.exec(BuildCommand.java:98)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:524)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:192)
	at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:573)
	at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$2(GrpcServerImpl.java:624)
	at java.base/java.lang.Thread.run(Thread.java:834)

INFO: Elapsed time: 8.645s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (135 packages loaded, 1709 targets configured)
    Fetching @iron-flex-layout; fetching 4s
    Fetching @paper-button; fetching 4s
    Fetching @iron-menu-behavior; fetching 4s
Internal error thrown during build. Printing stack trace: java.util.UnknownFormatConversionException: Conversion = ' '
	at java.base/java.util.Formatter.checkText(Formatter.java:2732)
	at java.base/java.util.Formatter.parse(Formatter.java:2718)
	at java.base/java.util.Formatter.format(Formatter.java:2655)
	at java.base/java.util.Formatter.format(Formatter.java:2609)
	at java.base/java.lang.String.format(String.java:2897)
	at com.google.devtools.build.lib.skyframe.SkyframeDependencyResolver.getTargets(SkyframeDependencyResolver.java:145)
	at com.google.devtools.build.lib.analysis.DependencyResolver.dependentNodeMap(DependencyResolver.java:274)
	at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.computeDependencies(ConfiguredTargetFunction.java:562)
	at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.compute(ConfiguredTargetFunction.java:317)
	at com.google.devtools.build.skyframe.AbstractExceptionalParallelEvaluator.bubbleErrorUp(AbstractExceptionalParallelEvaluator.java:495)
	at com.google.devtools.build.skyframe.ParallelEvaluator.bubbleErrorUpExceptionally(ParallelEvaluator.java:77)
	at com.google.devtools.build.skyframe.AbstractExceptionalParallelEvaluator.waitForCompletionAndConstructResult(AbstractExceptionalParallelEvaluator.java:282)
	at com.google.devtools.build.skyframe.AbstractExceptionalParallelEvaluator.doMutatingEvaluation(AbstractExceptionalParallelEvaluator.java:265)
	at com.google.devtools.build.skyframe.AbstractExceptionalParallelEvaluator.evalExceptionally(AbstractExceptionalParallelEvaluator.java:201)
	at com.google.devtools.build.skyframe.ParallelEvaluator.eval(ParallelEvaluator.java:70)
	at com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator.evaluate(InMemoryMemoizingEvaluator.java:205)
	at com.google.devtools.build.skyframe.SequentialBuildDriver.evaluate(SequentialBuildDriver.java:38)
	at com.google.devtools.build.lib.skyframe.SkyframeExecutor.configureTargets(SkyframeExecutor.java:2381)
	at com.google.devtools.build.lib.skyframe.SkyframeBuildView.configureTargets(SkyframeBuildView.java:373)
	at com.google.devtools.build.lib.analysis.BuildView.update(BuildView.java:399)
	at com.google.devtools.build.lib.buildtool.AnalysisPhaseRunner.runAnalysisPhase(AnalysisPhaseRunner.java:198)
	at com.google.devtools.build.lib.buildtool.AnalysisPhaseRunner.execute(AnalysisPhaseRunner.java:110)
	at com.google.devtools.build.lib.buildtool.BuildTool.buildTargets(BuildTool.java:141)
	at com.google.devtools.build.lib.buildtool.BuildTool.processRequest(BuildTool.java:268)
	at com.google.devtools.build.lib.runtime.commands.BuildCommand.exec(BuildCommand.java:98)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:524)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:192)
	at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:573)
	at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$2(GrpcServerImpl.java:624)
	at java.base/java.lang.Thread.run(Thread.java:834)
java.util.UnknownFormatConversionException: Conversion = ' '
	at java.base/java.util.Formatter.checkText(Formatter.java:2732)
	at java.base/java.util.Formatter.parse(Formatter.java:2718)
	at java.base/java.util.Formatter.format(Formatter.java:2655)
	at java.base/java.util.Formatter.format(Formatter.java:2609)
	at java.base/java.lang.String.format(String.java:2897)
	at com.google.devtools.build.lib.skyframe.SkyframeDependencyResolver.getTargets(SkyframeDependencyResolver.java:145)
	at com.google.devtools.build.lib.analysis.DependencyResolver.dependentNodeMap(DependencyResolver.java:274)
	at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.computeDependencies(ConfiguredTargetFunction.java:562)
	at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.compute(ConfiguredTargetFunction.java:317)
	at com.google.devtools.build.skyframe.AbstractExceptionalParallelEvaluator.bubbleErrorUp(AbstractExceptionalParallelEvaluator.java:495)
	at com.google.devtools.build.skyframe.ParallelEvaluator.bubbleErrorUpExceptionally(ParallelEvaluator.java:77)
	at com.google.devtools.build.skyframe.AbstractExceptionalParallelEvaluator.waitForCompletionAndConstructResult(AbstractExceptionalParallelEvaluator.java:282)
	at com.google.devtools.build.skyframe.AbstractExceptionalParallelEvaluator.doMutatingEvaluation(AbstractExceptionalParallelEvaluator.java:265)
	at com.google.devtools.build.skyframe.AbstractExceptionalParallelEvaluator.evalExceptionally(AbstractExceptionalParallelEvaluator.java:201)
	at com.google.devtools.build.skyframe.ParallelEvaluator.eval(ParallelEvaluator.java:70)
	at com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator.evaluate(InMemoryMemoizingEvaluator.java:205)
	at com.google.devtools.build.skyframe.SequentialBuildDriver.evaluate(SequentialBuildDriver.java:38)
	at com.google.devtools.build.lib.skyframe.SkyframeExecutor.configureTargets(SkyframeExecutor.java:2381)
	at com.google.devtools.build.lib.skyframe.SkyframeBuildView.configureTargets(SkyframeBuildView.java:373)
	at com.google.devtools.build.lib.analysis.BuildView.update(BuildView.java:399)
	at com.google.devtools.build.lib.buildtool.AnalysisPhaseRunner.runAnalysisPhase(AnalysisPhaseRunner.java:198)
	at com.google.devtools.build.lib.buildtool.AnalysisPhaseRunner.execute(AnalysisPhaseRunner.java:110)
	at com.google.devtools.build.lib.buildtool.BuildTool.buildTargets(BuildTool.java:141)
	at com.google.devtools.build.lib.buildtool.BuildTool.processRequest(BuildTool.java:268)
	at com.google.devtools.build.lib.runtime.commands.BuildCommand.exec(BuildCommand.java:98)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:524)
FAILED: Build did NOT complete successfully (135 packages loaded, 1709 targets configured)
    Fetching @iron-flex-layout; fetching 4s
    Fetching @paper-button; fetching 4s
    Fetching @iron-menu-behavior; fetching 4s

qtprojectorg pushed a commit to qtqa/gerrit that referenced this issue Jul 4, 2019
Bazel 0.27 flipped incompatible Starlark flag:
--incompatible_string_join_requires_strings, see: [1] for
more details.

[1] bazelbuild/bazel#7802

Change-Id: I639948584a65decfbe873c214c027290d9401c56
lucamilanesio pushed a commit to GerritCodeReview/bazlets that referenced this issue Jul 4, 2019
Bazel 0.27 flipped incompatible Starlark flag:
--incompatible_string_join_requires_strings, see: [1] for
more details.

[1] bazelbuild/bazel#7802

Change-Id: I7c0649a7cca6139c49f13c2f67cae857096b5cf5
@laurentlb
Copy link
Contributor Author

laurentlb commented Jul 4, 2019

Internal errors or Java stack traces are never expected. I've filed a separate bug for it.

This shouldn't block you though: the error still contains the important information about the bzl file.

qtprojectorg pushed a commit to qtqa/gerrit that referenced this issue Jul 8, 2019
Bazel 0.27 flipped incompatible Starlark flag:
--incompatible_string_join_requires_strings, see: [1] for
more details.

[1] bazelbuild/bazel#7802

Change-Id: Id8588f65ba34a084d82f282da180fb8b35ef48ac
irengrig pushed a commit to irengrig/bazel that referenced this issue Jul 15, 2019
Fixes bazelbuild#7802

RELNOTES: --incompatible_string_join_requires_strings is now enabled by default
PiperOrigin-RevId: 250159837
@lberki
Copy link
Contributor

lberki commented Jul 22, 2019

rules_scala fails with this flag:

https://travis-ci.org/bazelbuild/rules_scala/jobs/561942959

How was it flipped then?

rkolchmeyer added a commit to rkolchmeyer/cos-customizer that referenced this issue Aug 7, 2019
Also update WORKSPACE to resolve build failure. Failure had the
following error:

INFO: Call stack for the definition of repository 'package_bundle' which is a _dpkg_list (rule definition at /builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/distroless/package_manager/dpkg.bzl:19:14):
- /builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/distroless/package_manager/dpkg.bzl:74:3
- /workspace/WORKSPACE:173:1
ERROR: An error occurred during the fetch of repository 'package_bundle':
sequence element must be a string (got 'path'). See bazelbuild/bazel#7802 for information about --incompatible_string_join_requires_strings.
rkolchmeyer added a commit to GoogleCloudPlatform/cos-customizer that referenced this issue Aug 7, 2019
Also update WORKSPACE to resolve build failure. Failure had the
following error:

INFO: Call stack for the definition of repository 'package_bundle' which is a _dpkg_list (rule definition at /builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/distroless/package_manager/dpkg.bzl:19:14):
- /builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/distroless/package_manager/dpkg.bzl:74:3
- /workspace/WORKSPACE:173:1
ERROR: An error occurred during the fetch of repository 'package_bundle':
sequence element must be a string (got 'path'). See bazelbuild/bazel#7802 for information about --incompatible_string_join_requires_strings.
bazel-io pushed a commit that referenced this issue Nov 18, 2019
#7802

RELNOTES: None.
PiperOrigin-RevId: 281069144
aherrmann added a commit to tweag/rules_haskell that referenced this issue Nov 25, 2019
The call to `fail` itself failed with
```
	File "/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/8b8a09a5fc28e77c5514319513adb8f9/external/rules_haskell/haskell/ghc_bindist.bzl", line 197, in "{0} failed, aborting creation of GHC bindist".format
		" ".join(args)
sequence element must be a string (got 'path'). See bazelbuild/bazel#7802 for information about --incompatible_string_join_requires_strings.
```

This change switches to a shared implementation that fixes this issue.
luca-digrazia pushed a commit to luca-digrazia/DatasetCommitsDiffSearch that referenced this issue Sep 4, 2022
luca-digrazia pushed a commit to luca-digrazia/DatasetCommitsDiffSearch that referenced this issue Sep 4, 2022
    bazelbuild/bazel#7802

    RELNOTES:
      A new flag `--incompatible_string_join_requires_strings` is introduced. The sequence argument of `string.join` must contain only string elements.
    PiperOrigin-RevId: 240775005
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompatible-change Incompatible/breaking change P2 We'll consider working on this in future. (Assignee optional)
Projects
None yet
Development

No branches or pull requests

4 participants