-
Notifications
You must be signed in to change notification settings - Fork 983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to upload new project with two factor auth enabled? #14070
Comments
Hi @grantjenks, sorry you're having trouble and thanks for the report. The two ways to create projects when 2FA is enabled are:
This might be a bug on our end: I see that you correctly added a "pending publisher" for https://github.com/grantjenks/python-typesense-server-wrapper. I also see that during the workflow run, https://pypi.org/p/python-typesense-server-wrapper/ actually did get created and the pending publisher was correctly converted it to an actual publisher (you can see it here: https://pypi.org/manage/project/python-typesense-server-wrapper/settings/publishing/). However, no releases were published. In this case, the token exchange prior to the upload successfully created the project, but by the time the request to upload the releases was made, the following request thought the project didn't exist for some reason, and so it failed: warehouse/warehouse/forklift/legacy.py Lines 946 to 958 in 30de226
I'm not sure what's happening here: it's possible the two requests happened too quickly and the creation of the project wasn't committed to our database before the upload request happened. At any rate, the error message is wrong and potentially confusing, so we should look into improving that as well. The good news is you should be able to re-run that same workflow and it should work successfully this time. (cc @webknjaz @woodruffw for any thoughts they might have) |
Yeah, this is odd -- to have gotten that far Agreed about the error message being confusing though; I'll give some thought to what a better one would be. |
That assessment seems fair. Too bad we can't reliably know if it's safe to call twine, otherwise sticking a retry would've helped on the action side... |
Can you clarify what you mean by this? |
Thanks for the quick responses, all! I tried re-running the workflow but failed the same way. Log at https://github.com/grantjenks/python-typesense-server-wrapper/actions/runs/5480180242/jobs/9985978215 Anything else I can do to get the GHA working? |
Aha, @grantjenks, should the project name be |
When we run |
This must be it. If these don't match, PyPI can't find a publisher trust connection for that... I wonder if PyPI should silently normalize the project name both on creation and upload.. cc @woodruffw Also, I'd argue that the error message could be improved — just by reading the log, I couldn't understand why it's talking about some service identity. And that's me with likely better understanding of the context than an average user. Can we provide simpler explanation there? |
@webknjaz We already normalize the project name, but even with normalization, the project names here aren't the same.
Yes, looks like this is an edge case we hadn't considered. I think at this point we have enough information to provide an error message like:
|
Yep, agreed with @di -- I can make a PR to improve this error message in a moment. |
Ah, I missed that they differ more.. @woodruffw how about improving the form on PyPI with extra explanation that the name shouldn't come from the repo slug but from something like |
Yeah, I'll think about the language there -- we might not want to reference specific sources of metadata since PyPI is agnostic to whether it's coming from Either way, I think we should add this as a troubleshooting item to the trusted publisher docs as well. I'll include that in the error message work. |
#14082 improves the error here and adds a corresponding troubleshooting section. |
Thanks all. I fixed the name on PyPI and the job on GitHub worked. Sorry for the mistake. |
Nothing to be sorry for -- this is a reasonable source of confusion, and you helped us find and fix a misleading error message! |
Describe the bug
I want to upload a new project and my account has two factor auth enabled. When I try to upload locally with twine, I get an error saying that I cannot use my password because I have two factor auth enabled. Then I try uploading from GitHub using the new OIDC functionality but I get another error saying that non-user accounts cannot create new projects.
Expected behavior
There is a way to upload to PyPI with a two factor auth account.
To Reproduce
GitHub action log: https://github.com/grantjenks/python-typesense-server-wrapper/actions/runs/5480180242/jobs/9983014023
My Platform
Python 3.11 from GitHub Codespaces and GitHub Actions on ubuntu-latest.
Additional context
https://stackoverflow.com/questions/57506394/how-to-upload-package-to-pypi-with-two-factor-enabled Says to use api tokens but I can’t create those for a new project
https://stackoverflow.com/questions/62532237/how-can-i-create-an-api-token-on-pypi-for-a-new-project/62535186#62535186 Says that I need to create a global token and swap it later but that doesn’t seem right
Single-use API token to create new package #6378 Is closed but the resolution is unclear to me. The resolution there seems to be to use OIDC but that didn’t work for me.
The text was updated successfully, but these errors were encountered: