CircleCI failing at stage Upload Coverage Results ValueError: The provided slug is invalid
Hello,
Having some trouble getting circleci integrated with codecov. Consistently getting the below trace.
./"codecov" create-commit -t <redacted>
info - 2024-07-11 22:14:02,575 -- ci service found: circleci
warning - 2024-07-11 22:14:02,580 -- No config file could be found. Ignoring config.
Traceback (most recent call last):
File "codecov_cli/main.py", line 85, in <module>
File "codecov_cli/main.py", line 81, in run
File "click/core.py", line 1157, in __call__
File "click/core.py", line 1078, in main
File "click/core.py", line 1688, in invoke
File "click/core.py", line 1434, in invoke
File "click/core.py", line 783, in invoke
File "click/decorators.py", line 33, in new_func
File "codecov_cli/commands/commit.py", line 64, in create_commit
File "codecov_cli/services/commit/__init__.py", line 27, in create_commit_logic
File "codecov_cli/helpers/encoder.py", line 10, in encode_slug
ValueError: The provided slug is invalid
[468] Failed to execute script 'main' due to unhandled exception!
Exited with code exit status 1
Tried creating a global token, as my regenerate at the repo level wasn't working, no change. My repo is activated. Not really sure what else to try here.
This is my .circleci/config.yml
Mostly left it as is from the auto generated one, main changes I performed:
- change from pip to pipenv
- change to python 12
- tried a couple different versions of the orb (4, 4.0.1 (one in the codecov instructions), 4.1.0)
version: 2.1
orbs:
node: circleci/node@5
python: circleci/python@2
codecov: codecov/[email protected]
jobs:
test-and-upload-python:
docker:
- image: cimg/python:3.12
steps:
- checkout
- run: pipenv install
- run: pipenv run pytest --cov .
- codecov/upload
workflows:
upload-to-codecov:
jobs:
- test-and-upload-python
Any guidance would be appreciated.
I'm having the same issue. Did you manage to solve it?
@tomdeabreucodes are you still running into this? can you try running 5.0.0?
@thomasrockhu-codecov I have the same issue with 5.0.0. We're using GitHub enterprise (cloud) if it matters.
==> CLI integrity verified
-> Token of length 36 detected
==> Running create-commit
./codecov create-commit -t <redacted>
info - 2024-10-27 23:31:33,324 -- ci service found: circleci
Traceback (most recent call last):
File "codecov_cli/main.py", line 87, in <module>
File "codecov_cli/main.py", line 83, in run
File "click/core.py", line 1157, in __call__
File "click/core.py", line 1078, in main
File "click/core.py", line 1688, in invoke
File "click/core.py", line 1434, in invoke
File "click/core.py", line 783, in invoke
File "click/decorators.py", line 33, in new_func
File "codecov_cli/commands/commit.py", line 58, in create_commit
File "codecov_cli/services/commit/__init__.py", line 28, in create_commit_logic
File "codecov_cli/helpers/encoder.py", line 10, in encode_slug
ValueError: The provided slug is invalid
[PYI-3303:ERROR] Failed to execute script 'main' due to unhandled exception!
==> Failed to create-commit
@leshik ah! that does matter. what happens if you add
git_service: github_enterprise
as an argument? @leshik how were you running with 4.x?
@thomasrockhu-codecov This flag doesn't change things, but I enabled verbose logging, and I think the issue is the space in the slug. Apparently, the orb uses CircleCI's <org_name>/<project_name> for slug, and our org name has space in the middle. I thought the slug is based on the GitHub org name and repo, what do you think could be the best way to resolve this? We can rename the org in CircleCI, but it feels sub-optimal.
@leshik oh! wild! ok, that really helps, let me dig into this a bit more
Hey @thomasrockhu-codecov, do you have any news on this?
no @leshik I'm still digging into this
@leshik to be clear, in GitHub your org is something like MyOrg, but in CircleCI it is My Org, is that correct?
For reference, we pull CIRCLE_PROJECT_USERNAME as documented here to get the owner name which the docs state is
The GitHub or Bitbucket username of the current project.
@thomasrockhu-codecov correct, but also they are two completely different names because it's a corporation that owns multiple companies. I'd prefer codecov used GitHub org/repo instead of Circle's org/project.
What I see in debug log is not github username. Maybe the documentation is incorrect? I see the circle org name there.
@leshik if it helps unblock you, you can supply the slug to the orb manually via
- slug: "your org/your project"
@thomasrockhu-codecov this did the trick, thank you!
If you want to make it work by default, here is the context: our organization name in CircleCI is HSI APAC, and the project name is Donesafe. OTOH, our GitHub organization is DoneSafe, and the repository is donesafe. Before manually setting the slug, the payload that I saw in the verbose log was:
{
...
"slug": "HSI APAC/Donesafe"
}
which resulted in the error.
After setting it as you suggested to:
- codecov/upload:
slug: DoneSafe/donesafe
verbose: true
the log is now:
{
...
"slug": "DoneSafe/donesafe"
}
and the error is gone.
Awesome @leshik, wish I had thought of that sooner.
I'll close this issue out for now as I've opened an issue internally to ping CircleCI about the discrepancy