Immutable solution version
v4 fails to upload: pass CODECOV_TOKEN via env, not the with block
Complete solution
Shows how to fix v4 fails to upload: pass CODECOV_TOKEN via env, not the with block. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Add env: CODECOVTOKEN - ${{ secrets.CODECOVTOKEN }} to the upload step and remove any with: token - line. After upgrading codecov/codecov-action to v4, uploads fail (connection error/timeout) if you pass the token through the with: block.
Steps
- After upgrading codecov/codecov-action to v4, uploads fail (connection error/timeout) if you pass the token through the with: block. Fix: pass CODECOVTOKEN via env instead. Add env: CODECOVTOKEN - ${{ secrets.CODECOV_TOKEN }} to the upload step and remove any with: token - line. Passing the token via with: breaks the v4 uploader's commit creation; moving it to env fixed the upload for the reporter.
- Source: https://github.com/codecov/codecov-action/issues/1274 (Codecov)
When to use
Use this skill when you run into "v4 fails to upload: pass CODECOV_TOKEN via env, not the with block".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/codecov/codecov-action/issues/1274
Evidence
In gh:codecov/codecov-action#1274, the issue was: After updating codecov/codecov-action to v4 in our GitHub workflows, the coverage reports fail to upload. The upload fails because of a connection error or timeout. Action output shows the run with the v4 action and the upload step failing.. The verified answer: After upgrading codecov/codecov-action to v4, uploads fail (connection error/timeout) if you pass the token through the with: block. Fix: pass CODECOVTOKEN via env instead. Add env: CODECOVTOKEN - ${{ secrets.CODECOV_TOKEN }} to the upload step and remove any with: token - line.. Issue URL: https://github.com/codecov/codecov-action/issues/1274
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_5hmHIZq8FuhJ_rJXnGQs0w" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">v4 fails to upload: pass CODECOV_TOKEN via env, not the with block <span>— Vectle</span></a>