Skip to content

[Bug]: PROTOC_TOOLCHAIN_FLAGS contains duplicate keys in a dict #85

@mislavmandaricaxilis

Description

@mislavmandaricaxilis

What happened?

We're trying out bazel-preset.bzl and as I was cleaning up our flags I stumbled upon PROTOC_TOOLCHAIN_FLAGS.

When testing it out from HEAD I got a build failure as the dict contains multiple flags. This should probably be resolved on bazel-preset.bzl level, because as it's public API defined right now, it's not possible to provide multiple values for the same flag (eg. can't set multiple --repo_env or --action_env flags).

ERROR: Traceback (most recent call last):
        File "/private/var/tmp/_bazel_username/f5a8e2c9b1d0f3a7e6b4c2d1f0a9b8c7/external/toolchains_protoc+/protoc/flags.bzl", line 19, column 20, in <toplevel>
                "per_file_copt": struct(
Error: dictionary expression has duplicate key: "per_file_copt"
WARNING: Target pattern parsing failed.
ERROR: Skipping '//tools/bazelrc_preset': error loading package 'tools/bazelrc_preset': initialization of module 'protoc/flags.bzl' failed
ERROR: error loading package 'tools/bazelrc_preset': initialization of module 'protoc/flags.bzl' failed
INFO: Elapsed time: 0.774s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

Version

Development (host) and target OS/architectures: darwin/arm64

Output of bazel --version: bazel 8.1.1

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:
bazel_dep(name = "bazelrc-preset.bzl", version = "1.1.0")
bazel_dep(name = "toolchains_protoc", version = "0.4.3")

Language(s) and/or frameworks involved: /

How to reproduce

# MODULE.bazel
bazel_dep(name = "bazelrc-preset.bzl", version = "1.1.0")
bazel_dep(name = "toolchains_protoc", version = "0.4.3")
git_override(
    module_name = "toolchains_protoc",
    commit = "4ef6589ef740f70ef34f8b34474ebb36933b8803",
    remote = "https://github.com/aspect-build/toolchains_protoc",
)

# BUILD.bazel
load("@bazelrc-preset.bzl", "bazelrc_preset")
load("@toolchains_protoc//protoc:flags.bzl", "PROTOC_TOOLCHAIN_FLAGS")

bazelrc_preset(
    name = "preset",
    extra_presets = PROTOC_TOOLCHAIN_FLAGS,
)

Any other information?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions