Skip to content

fix(blocks): stop base64 from wrapping the git auth header - #88

Merged
Yan Xue (yanxue06) merged 1 commit into
mainfrom
fix/base64-auth-header-wrap
Jun 8, 2026
Merged

fix(blocks): stop base64 from wrapping the git auth header#88
Yan Xue (yanxue06) merged 1 commit into
mainfrom
fix/base64-auth-header-wrap

Conversation

@yanxue06

@yanxue06 Yan Xue (yanxue06) commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Hi — I was trying to work out why a release wouldn't publish, and I think I found a small thing. Writing down what I saw in case I got part of it wrong.

What I saw

A release failed at git pull with:

fatal: unable to access 'https://github.com/.../': Failed sending HTTP request

The odd part: it failed in about 60 milliseconds. That felt too fast to be a network or GitHub problem — almost like the request never actually left the machine.

What I think is going on

These blocks build a git auth header like this:

AUTH=$(echo -n "x-access-token:${TOKEN}" | base64)

I learned that base64 on Linux adds a line break every 76 characters by default. So if the token is long enough, $AUTH ends up with a newline sitting in the middle of it. That newline goes straight into an HTTP header — and newer versions of curl refuse to send a header that has a newline in it. So the pull dies before it even tries to connect.

That also seems to explain two things I was confused about:

  • Why it only started failing recently — it broke right after the GitHub runner image moved to a newer curl. The older curl didn't mind the newline; the new one does.
  • Why it only hit one repo and not the others — repos that use the GitHub App token are fine, because that token is short enough that base64 never wraps it. The one that broke was falling back to a longer token, which tipped it past 76 characters.

The fix

Just strip the newlines — which is what update-skills/action.yaml already does:

AUTH=$(echo -n "x-access-token:${TOKEN}" | base64 | tr -d '\n')

I copied that exact line since it's already in the repo, so this is just making the other blocks match.

Why I don't think this breaks anything

For short tokens, base64 doesn't add a newline at all, so tr -d '\n' does nothing and those releases behave exactly as before. It only changes the long-token case — which is the one that's currently broken. So I believe it's safe, but I'd appreciate a second pair of eyes.

Changed the three blocks that were missing it:

  • bump-npm-version
  • bump-monorepo-versions
  • sync-crates-version

(update-skills already had the fix. update-docs and swift-build put the token in the URL instead of a base64 header, so they aren't affected.)

Did I get this right?

🤖 Generated with Claude Code


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed authentication header formatting in automated build processes to ensure reliable git operations during releases and version synchronization workflows.

base64 wraps at 76 cols by default, so a long enough token put a
newline inside the AUTHORIZATION extraheader. Newer curl (in the
updated runner image) rejects headers with embedded newlines, so
git pull died with 'Failed sending HTTP request' before sending.

Strip the newline with 'tr -d \n', matching the pattern already
used in update-skills. No-op for short tokens (no wrap), so the
currently-working App-token path is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 8, 2026 02:56
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3b6f477d-8889-4a6f-8b69-db2afa02befd

📥 Commits

Reviewing files that changed from the base of the PR and between 078b7e9 and 60750a8.

📒 Files selected for processing (3)
  • .github/blocks/bump-monorepo-versions/action.yaml
  • .github/blocks/bump-npm-version/action.yaml
  • .github/blocks/sync-crates-version/action.yaml
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: copilot-pull-request-reviewer
  • GitHub Check: check-skills / check-skills
  • GitHub Check: check-readme / check-readme
🔇 Additional comments (3)
.github/blocks/bump-monorepo-versions/action.yaml (1)

276-276: LGTM!

.github/blocks/bump-npm-version/action.yaml (1)

53-53: LGTM!

.github/blocks/sync-crates-version/action.yaml (1)

59-59: LGTM!


📝 Walkthrough

Walkthrough

Three composite GitHub Actions used for version bumping and synchronization are updated to remove newlines from base64-encoded authentication tokens. The AUTH variable generation is modified in each action to pipe the base64 output through tr -d '\n' before setting the Authorization header for git operations.

Changes

GitHub Actions authentication header newline cleanup

Layer / File(s) Summary
AUTH header newline stripping across workflow actions
.github/blocks/bump-monorepo-versions/action.yaml, .github/blocks/bump-npm-version/action.yaml, .github/blocks/sync-crates-version/action.yaml
Base64-encoded GitHub tokens are piped through tr -d '\n' to strip newlines when computing the AUTH value for http.https://github.com/.extraheader git configuration across all three version-management actions.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A rabbit hops through workflows with glee,
Stripping away newlines, making them clean,
Three actions aligned in consistent harmony,
Auth headers polished, the neatest they've been! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing base64 wrapping (newline injection) in git auth headers across GitHub Actions blocks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/base64-auth-header-wrap

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

📄 README may need an update

This PR introduces changes that might not be reflected in README.md.

Reason: README.md is missing the newly supported optional app-id and app-private-key inputs on sync-crates-version, so it no longer fully documents the current public configuration surface of the changed actions.

This is an automated check powered by AI. If the README is intentionally unchanged, feel free to ignore this.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes intermittent git pull/git push failures in several GitHub Actions “blocks” by ensuring the Base64-encoded HTTP Authorization header value never contains embedded newlines (which can happen when base64 wraps output at 76 chars on some platforms and can be rejected by newer curl versions).

Changes:

  • Strip newline characters from the Base64-encoded x-access-token:${TOKEN} value via | tr -d '\n'.
  • Apply the same header-hardening already used in update-skills to the remaining affected blocks.
  • Update all occurrences of the http.https://github.com/.extraheader auth header construction in the targeted blocks.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
.github/blocks/bump-npm-version/action.yaml Prevent wrapped Base64 output from injecting a newline into the GitHub auth header.
.github/blocks/bump-monorepo-versions/action.yaml Prevent wrapped Base64 output from injecting a newline into the GitHub auth header during version bump/push.
.github/blocks/sync-crates-version/action.yaml Prevent wrapped Base64 output from injecting a newline into the GitHub auth header for crate version sync workflows.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yanxue06
Yan Xue (yanxue06) merged commit 9f1c649 into main Jun 8, 2026
4 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