8000 fix(ci): strip newlines from base64 encoded auth header in incremental approval by VLukiantsev · Pull Request #820 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content

fix(ci): strip newlines from base64 encoded auth header in incremental approval - #820

Merged
VLukiantsev merged 1 commit into
mainfrom
fix/ci-auth-header-base64-newline
Sep 8, 2026
Merged

VLukiantsev merged 1 commit into
mainfrom
fix/ci-auth-header-base64-newline

Conversation

@VLukiantsev
Copy link
Copy Markdown
Collaborator

Summary

Strips newline characters from the base64-encoded authorization header in the incremental PR approval workflow step that restores trusted scripts from the base branch, fixing fatal: unable to access ...: Failed sending HTTP request observed on PR #813.

Motivation & Context

In Step 2 (Restore trusted scripts and ownership from base branch) of .github/workflows/incremental-pr-approval.yml, AUTH_HEADER was constructed via:

AUTH_HEADER="AUTHORIZATION: basic $(printf "x-access-token:%s" "$GITHUB_TOKEN" | base64)"

By default, GNU base64 wraps output lines at 76 columns. When x-access-token:<token> exceeds 57 bytes (which occurs with standard ARC runner installation tokens), base64 inserts a newline character (\n) into the middle of the base64 string.
Because command substitution $(...) only strips trailing newlines, the intermediate newline was preserved in AUTH_HEADER. When passed to git -c http.extraheader=..., libcurl's header validation detected an unescaped LF and aborted locally with CURLE_SEND_ERROR (fatal: unable to access ...: Failed sending HTTP request) before transmitting the request.

Key Changes

  • .github/workflows/incremental-pr-approval.yml:
    • Piped base64 through tr -d '\n' in Step 2 to guarantee a single-line base64 authorization string regardless of token length.
    • Standardized the header casing to Authorization: Basic to match git-range-diff.js:60.

Assumptions

None — requirements were fully specified and reproduced from PR #813 run 34220332798.

Verification & Testing

  • Commands Executed:
    • node --test .github/scripts/*.test.js: All 118 unit tests passed cleanly.
    • ./.githooks/pre-commit: All linter and pre-commit checks passed cleanly.
    • ./tools/analyze_diff_size.py --base-ref origin/main...: Verified diff size.
    • Local reproduction testing confirmed that git -c http.extraheader=... aborts with Failed sending HTTP request when newlines are present, and succeeds when piped through tr -d '\n'.

Related Issues / Bugs

Fixes workflow fetch failure on PR #813 (run 34220332798)

TAG=agy
CONV=ced76c7b-e554-4b82-8631-a07a1a2f203d

…l approval

GNU base64 wraps output at 76 characters by default. When GITHUB_TOKEN
is longer than 40 characters (as with ARC runner installation tokens),
a newline is introduced into the middle of the base64 string.
Command substitution only strips trailing newlines, leaving the
intermediate newline in AUTH_HEADER. This caused git/curl to abort
with 'fatal: unable to access ...: Failed sending HTTP request'
due to header injection protection in libcurl.

Fix this by piping base64 through 'tr -d '\n'' and standardizing
header casing to 'Authorization: Basic'.

TAG=agy
CONV=ced76c7b-e554-4b82-8631-a07a1a2f203d
@gemini-code-assist
Copy link
Copy Markdown

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@VLukiantsev
VLukiantsev marked this pull request as ready for review September 8, 2026 11:56
@github-actions
github-actions Bot requested a review from janzak-dev September 8, 2026 11:56
@VLukiantsev
VLukiantsev added this pull request to the merge queue Sep 8, 2026
Merged via the queue into main with commit 8fdf201 Sep 8, 2026
12 checks passed
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

0