bazelbuild/bazel

Incorrect error handling of credential helper by Bazel

Open

#24,548 创建于 2024年12月3日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)Java (4,465 fork)batch import
P3help wantedteam-ExternalDepstype: bug

仓库指标

Star
 (25,384 star)
PR 合并指标
 (平均合并 22天 20小时) (30 天内合并 77 个 PR)

描述

Description of the bug:

Hi, I have an issue with handling errors when using the credential helper to authenticate with a private bazel registry instance. The authentication process works correctly, but the errors from the credential-helper (which is a bash script) are not handled properly. For example, if I exit the credential helper with a non zero exit code, I receive messages like: ERROR: Error computing the main repository mapping: module not found in registries: and after multiple tries Error retrieving auth headers, continuing without: Failed to get credentials for '<registry>' from helper '<helper>': process was interrupted

instead of the expected:

WARNING: Error retrieving auth headers, continuing without: Failed to get credentials for '<file>' from helper '<helper>': process exited with code 2. stderr: You need to generate refresh token by running script: <script> - The problem is that this last warning message only appears when I run the bazel build command multiple times with the helper added as common for all entries - common --credential_helper=<helper> . However, if I set credential helper for specific host with pattern or not - common --credential_helper=<host>=<helper>, the WARNING never appears.

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

The simplest credential helper can look like that:

#!/bin/bash

echo "Token could not be created." >&2
exit 1

Then add the credential helper in .bazelrc

common \
    --enable_bzlmod \
    --registry https://<registry-host>/ \
    --registry https://bcr.bazel.build/ \
    --credential_helper=<registry-host>=credential-helper

Which operating system are you running Bazel on?

SUSE Linux Enterprise Server 15 SP5

What is the output of bazel info release?

release 7.3.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

Similar issues:

Any other information, logs, or outputs that you want to share?

No response

贡献者指南