Skip to content

fix(bazel): add build_directives to com_github_spf13_afero for golang.org/x/text deps#43906

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/fix-afero-missing-dependencies
Closed

fix(bazel): add build_directives to com_github_spf13_afero for golang.org/x/text deps#43906
Copilot wants to merge 2 commits intomainfrom
copilot/fix-afero-missing-dependencies

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 11, 2026

CI failing with compilepkg: missing strict dependencies for afero/util.go importing golang.org/x/text/{runes,transform,unicode/norm} — the go_repository lacked build_directives to resolve these against the already-pinned @org_golang_x_text.

Change

  • Add build_directives to com_github_spf13_afero in bazel/dependency_imports.bzl, matching the pattern used in org_golang_google_grpc and similar repos:
go_repository(
    name = "com_github_spf13_afero",
    ...
    build_directives = [
        "gazelle:resolve go golang.org/x/text/runes @org_golang_x_text//runes",
        "gazelle:resolve go golang.org/x/text/transform @org_golang_x_text//transform",
        "gazelle:resolve go golang.org/x/text/unicode/norm @org_golang_x_text//unicode/norm",
    ],
)
Original prompt

Problem

CI is failing with compilepkg: missing strict dependencies errors for com_github_spf13_afero:

compilepkg: missing strict dependencies:
	/mnt/engflow/worker/work/7/exec/external/com_github_spf13_afero/util.go: import of "golang.org/x/text/runes"
	/mnt/engflow/worker/work/7/exec/external/com_github_spf13_afero/util.go: import of "golang.org/x/text/transform"
	/mnt/engflow/worker/work/7/exec/external/com_github_spf13_afero/util.go: import of "golang.org/x/text/unicode/norm"

Execution result: https://envoy.cluster.engflow.com/actions/executions/ChDAJYdW09tcipWHDNppTfrREgdkZWZhdWx0GiUKIFU-Ms3kbpWOCl5kZ-ZOwLtmTWHOdQ7RhuvL8EsUHS3aEKsC

Root Cause

The com_github_spf13_afero go_repository in bazel/dependency_imports.bzl does not have build_directives to resolve the golang.org/x/text sub-packages it imports against the already-pinned @org_golang_x_text repository.

Fix

Add build_directives to the com_github_spf13_afero go_repository definition in bazel/dependency_imports.bzl (line 169-175), following the same pattern used for org_golang_google_grpc and other repos that resolved similar issues (e.g., PR #40860).

Change the existing definition from:

    go_repository(
        name = "com_github_spf13_afero",
        importpath = "github.com/spf13/afero",
        sum = "h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY=",
        version = "v1.10.0",
        build_external = "external",
    )

To:

    go_repository(
        name = "com_github_spf13_afero",
        importpath = "github.com/spf13/afero",
        sum = "h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY=",
        version = "v1.10.0",
        build_external = "external",
        build_directives = [
            "gazelle:resolve go golang.org/x/text/runes @org_golang_x_text//runes",
            "gazelle:resolve go golang.org/x/text/transform @org_golang_x_text//transform",
            "gazelle:resolve go golang.org/x/text/unicode/norm @org_golang_x_text//unicode/norm",
        ],
    )

Only the file bazel/dependency_imports.bzl needs to be changed.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: ci just started failing ...

Configuration: f2fcbc7fec0f5a3043f1d0ef5128be9f0622a65d9e8354f2f7be6189b765633e

Execution platform: //bazel/platforms/rbe:linux_x64

Execution result: https://envoy.cluster.engflow.com/actions/executions/ChDAJYdW09tcipWHDNppTfrREgdkZWZhdWx0GiUKIFU-Ms3kbpWOCl5kZ-ZOwLtmTWHOdQ7RhuvL8EsUHS3aEKsC
compilepkg: missing strict dependencies:
/mnt/engflow/worker/work/7/exec/external/com_github_spf13_afero/util.go: import of "golang.org/x/text/runes"
/mnt/engflow/worker/work/7/exec/external/com_github_spf13_afero/util.go: import of "golang.org/x/text/transform"
/mnt/engflow/worker/work/7/exec/external/com_github_spf13_afero/util.go: import of "golang.org/x/text/unicode/norm"

we just fixed a bunch of these - so i think straightforward - no ?

Assistant:

Let me look at how similar strict dependency issues were recently fixed in the envoy repo, and examine the current state of the com_github_spf13_afero dependency.

Assistant: Now let me look at PR #40860 to see how the previous similar fix was done, and also check if com_github_spf13_afero has any deps specified:

Assistant: Yes, this is exactly the same pattern as the previous fix in PR #40860. The com_github_spf13_afero library (github.com/spf13/afero) imports packages from golang.org/x/text (runes, transform, unicode/norm), but the go_repository definition doesn't have build_directives to resolve those dependencies against the already-pinned @org_golang_x_text repo.

The fix is to add build_directives to the com_github_spf13_afero go_repository in bazel/dependency_imports.bzl, similar to how org_golang_google_grpc resolves its transitive deps. Specifically:

    go_repository(
        name = "com_github_spf13_afero",
        importpath = "github.com/spf13/afero",
        sum = "h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY=",
        version = "v1.10.0",
        build_external = "external",
        build_directives = [
            "gazelle:resolve go golang.org/x/text/runes @org_golang_x_text//runes",
            "gazelle:resolve go golang.org/x/text/transform @org_golang_x_text//transform",
            "gazelle:resolve go golang.org/x/text/unicode/norm @org_golang_x_text//unicode/norm",
        ],
    )

This tells Gazelle to resolve the three golang.org/x/text sub-packages that afero/util.go imports against the already-pinned @org_golang_x_text repository, rather than expecting them as direct strict dependencies.

Want me to create a PR with this fix?

User: yes

Assistant: I'...

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #43906 was opened by Copilot.

see: more, trace.

….org/x/text deps

Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix missing strict dependencies for com_github_spf13_afero fix(bazel): add build_directives to com_github_spf13_afero for golang.org/x/text deps Mar 11, 2026
@phlax phlax closed this Mar 11, 2026
@phlax phlax deleted the copilot/fix-afero-missing-dependencies branch April 13, 2026 11:44
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.

2 participants