gh-action-pypi-publish: Producing attestations fails when attempting publishing from unsupported reusable workflows (when enabled)
Howdy! We just had to turn off release attestations to get our releases running in langchain-ai/langchain. Haven’t had a chance to dig deeper into attestation configuration in order to see what we need to fix, and thought I’d file an issue in case others run into the same thing!
https://github.com/langchain-ai/langchain/pull/27765
Release Workflow
We run releases from the two workflow files edited in ^ that PR
- _release.yml, which calls _test_release.yml, and then publishes to pypi
- _test_release.yml for publishing to test.pypi
Error
We were seeing errors in your releases, e.g. in this workflow run: https://github.com/langchain-ai/langchain/actions/runs/11602468120/job/32307568692
Configuration of test release - 2 main things that look weird are /legacy/ and repository_url (we configure repository-url per docs)
Run pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: libs/core/dist/
verbose: true
print-hash: true
repository-url: https://test.pypi.org/legacy/
skip-existing: true
user: __token__
repository_url: https://upload.pypi.org/legacy/
packages_dir: dist
verify_metadata: true
skip_existing: false
print_hash: false
attestations: true
env:
POETRY_VERSION: 1.7.1
PYTHON_VERSION: [3](https://github.com/langchain-ai/langchain/actions/runs/11602468120/job/32307568692#step:5:3).10
Logs - partially redacted
Checking libs/core/dist/langchain_core-0.3.14-py3-none-any.whl: PASSED
Checking libs/core/dist/langchain_core-0.3.14.tar.gz: PASSED
Notice: Generating and uploading digital attestations
Fulcio client using URL: https://fulcio.sigstore.dev
TUF metadata: /root/.local/share/sigstore-python/tuf/https%3A%2F%2Ftuf-repo-cdn.sigstore.dev
TUF targets cache: /root/.cache/sigstore-python/tuf/https%3A%2F%2Ftuf-repo-cdn.sigstore.dev
Found and verified trusted root
Generating ephemeral keys...
Requesting ephemeral certificate...
Retrieving signed certificate...
Found <Name(O=sigstore.dev,CN=sigstore-intermediate)> as issuer, verifying if it is a ca
attempting to verify SCT with key ID xxx
Successfully verified SCT...
DSSE PAE: xxx
proposed: xxx
integrated: xxx
Transparency log entry created with index: 145293525
DSSE PAE: xxx
proposed: xxx
integrated: xxx
Transparency log entry created with index: 145293526
Showing hash values of files to be uploaded:
/github/workspace/libs/core/dist/langchain_core-0.3.14-py3-none-any.whl
SHA256: xxx
MD5: xxx
BLAKE2-256: xxx
/github/workspace/libs/core/dist/langchain_core-0.3.14.tar.gz
SHA256: xxx
MD5: xxx
BLAKE2-256: xxx
/github/workspace/libs/core/dist/langchain_core-0.3.14-py3-none-any.whl.publish.attestation
SHA256: xxx
MD5: xxx
BLAKE2-256: xxx
/github/workspace/libs/core/dist/langchain_core-0.3.14.tar.gz.publish.attestation
SHA256: xxx
MD5: xxx
BLAKE2-256: xxx
Uploading distributions to https://test.pypi.org/legacy/
INFO libs/core/dist/langchain_core-0.3.14-py3-none-any.whl (399.1 KB)
INFO libs/core/dist/langchain_core-0.3.14.tar.gz (320.2 KB)
INFO password set by command options
INFO username: __token__
INFO password: <hidden>
Uploading langchain_core-0.3.14-py3-none-any.whl
INFO Response from https://test.pypi.org/legacy/:
400 Bad Request
INFO <html>
<head>
<title>400 Could not verify the uploaded artifact using the included
attestation: Verification failed: 0 of 2 policies succeeded</title>
</head>
<body>
<h1>400 Could not verify the uploaded artifact using the included
attestation: Verification failed: 0 of 2 policies succeeded</h1>
The server could not comply with the request since it is either
malformed or otherwise incorrect.<br/><br/>
Could not verify the uploaded artifact using the included attestation:
Verification failed: 0 of 2 policies succeeded
</body>
</html>
ERROR HTTPError: 400 Bad Request from https://test.pypi.org/legacy/
Temporary Fix
https://github.com/langchain-ai/langchain/pull/27765
We turned off attestations with attestations: false
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 58 (30 by maintainers)
Commits related to this issue
- ci: Set attestations to false This is a work around for https://github.com/pypa/gh-action-pypi-publish/issues/283 — committed to ietf-tools/svgcheck by kesara 2 years ago
- check: ignore attestations, like signatures This fixes a bug that I accidentally introduced with attestations support: `twine upload` learned the difference between distributions and attestations, bu... — committed to woodruffw-forks/twine by woodruffw 2 years ago
- check: ignore attestations, like signatures This fixes a bug that I accidentally introduced with attestations support: `twine upload` learned the difference between distributions and attestations, bu... — committed to pypa/twine by woodruffw 2 years ago
- ci(gha): workaround pypa publish Possibly related issue: pypa/gh-action-pypi-publish#283. — committed to seoklab/nurikit by jnooree 2 years ago
- ci(gha): bump publish action to v1 and instead disable attestations Also see: pypa/gh-action-pypi-publish#283. — committed to seoklab/nurikit by jnooree 2 years ago
- ci: Set attestations to false (#63) This is a work around for https://github.com/pypa/gh-action-pypi-publish/issues/283 — committed to ietf-tools/svgcheck by kesara 2 years ago
- Temporarily disable attestations when publishing Workaround for https://github.com/pypa/gh-action-pypi-publish/issues/283 — committed to spine-tools/spine-conductor by soininen 2 years ago
- Comment out TestPyPI publishing It's currently broken (https://github.com/pypa/gh-action-pypi-publish/issues/283) — committed to asmeurer/array-api-strict by asmeurer 2 years ago
- Skip uploading to test PyPI for now. Details for why in https://github.com/pypa/gh-action-pypi-publish/issues/283. — committed to adamghill/dj-angles by adamghill 2 years ago
- ci: Recommendation is to use separate jobs for PyPI and TestPyPI pypa/gh-action-pypi-publish#283 — committed to open-contracting/kingfisher-colab by jpmckinney 2 years ago
- ci: Recommendation is to use separate jobs for PyPI and TestPyPI pypa/gh-action-pypi-publish#283 (replace other workaround) — committed to open-contracting/lib-cove-oc4ids by jpmckinney 2 years ago
- ci: Set attestations: false See https://github.com/pypa/gh-action-pypi-publish/issues/283 — committed to ietf-tools/xml2rfc by kesara 2 years ago
- ci: Fix publishing workflow issues (#1188) * ci: Refactor publish input * ci: Add ability skip test PyPI publishing * ci: Set attestations: false See https://github.com/pypa/gh-action-pypi-p... — committed to ietf-tools/xml2rfc by kesara 2 years ago
- ci: Disable attestations on TestPyPI https://github.com/pypa/gh-action-pypi-publish/issues/283#issuecomment-2504200656 — committed to indico/flask-multipass by ThiefMaster 2 years ago
- chore: split pypi and pypi test jobs to enable proper attestation Related: https://github.com/pypa/gh-action-pypi-publish/issues/283 — committed to freqtrade/freqtrade by xmatthias 2 years ago
- Fix PyPI publishing (#158) Running a publish to TestPyPI immediately followed by a publish to the "real" PyPI triggered [an error](https://github.com/foxglove/schemas/actions/runs/12283736365/job/3... — committed to foxglove/foxglove-sdk by jtbandes 2 years ago
- publish: disable attestations, tmp comment out CC https://github.com/pypa/gh-action-pypi-publish/issues/283#issuecomment-2499296440 — committed to pypdfium2-team/pypdfium2 by mara004 2 years ago
- ci: Disable attestations on publishing to PyPI from reusable workflow Related: https://github.com/pypa/gh-action-pypi-publish/issues/283 — committed to playpauseandstop/pre-commit-run-hook-entry by playpauseandstop 2 years ago
- ci: Disable attestations on publishing to PyPI from reusable workflow (#109) Related: https://github.com/pypa/gh-action-pypi-publish/issues/283 — committed to playpauseandstop/pre-commit-run-hook-entry by playpauseandstop 2 years ago
- CI: Separate jobs for publishing to TestPyPI and PyPI Have a dedicated build distribution job, and split the publish to TestPyPI and PyPI jobs, to workaround attestation file issue. Xref https://gith... — committed to GenericMappingTools/pygmt by weiji14 2 years ago
There’s a pretty big disparity between how most users think of TestPyPI and how the packaging maintainers think of it (this is not the first instance I’ve noticed of this).
Most users think of it as a way to test the full release process in a sandbox before doing the final release. If this isn’t what it is, you should really consider making it into that, because that’s what’s useful to people. The principle issue is that pushing to PyPI is a destructive process, since releases cannot be deleted once they are pushed, so it’s useful to have something to run a “test deployment” on (I admit the current TestPyPI doesn’t actually completely work for this because releases cannot be deleted from it either, but it’s better than nothing).
According to the previous comment yes because there’s also a check in this workflow itself.
It would be great if you could fix the workflow so that this just works here, even if it isn’t recommended. I have a lot of release workflows that upload to testpypi then upload to real pypi that used to work just fine and it would be nice if they could continue to work.
I’m a little reluctant to go around trying to refactor my publishing GitHub Actions file. What I have works (or at least used to). I’m not an expert on GitHub Actions (someone else wrote this file initially), and this one in particular is annoying to modify because you can’t really test that it works without doing a release, which itself is tough because PyPI doesn’t let you undo a release. Plus so many steps have to be done manually by typing stuff into a form on pypi.org or clicking around in the GitHub settings. If you want to make a PR to my project doing whatever fix you are suggesting, go for it.
Otherwise, I’m most likely going to just permanently disable either TestPyPI uploading or attestations in the job, since those seem to be the cause of the issue and that should fix the issue going forward, as I understand it.
This worked for me when pubslishing for test PyPI, but I got the same error when the GHA tries to publish to real PyPI.
Test PyPI:
PyPI:
Yes, this is essentially the rationale: immutable files are an important security invariant on the index itself. I agree that the community would benefit from a better automatable testing ground, which TestPyPI itself can probably never be. I don’t have super strong opinions on what that should be, other than that
twine checkis a great pre-existing UX that should probably provide stronger guarantees.We’re currently working on that, stay tuned 🙂
Random idea: Why not have atomic publishing? That way either the whole release fails or succeeds, but you’d never end up with something partially published where just some files are missing.
This would also help with cases where a release runs into quota limits (which happened e.g. for an
uvrelease a few months ago, where they had to yank the whole release while waiting for a quota increase…).(And in case, it wasn’t clear, if PyPI actually let you delete and redo broken releases, this wouldn’t be nearly so big of an issue. I’ve never understood why there has always been such a strong pushback against allowing that)
This is not true. I’ve had testpypi fail because of a broken build, which saved me because it never got to the real upload phase. The issue (IIRC) was that one release file that was uploaded was fine, and “created” the release, but a subsequent file had some issue.
Of course, as noted, there’s no way to delete releases from testpypi, so after doing this I had to temporarily disable the testpypi to make the actual release work, so it’s still not actually ideal for this particular use-case.
This project doesn’t control
twine’s release schedule.I understand your frustration, and I’m sorry that this bug bit you. At the same time, I don’t think it’s true that this makes things “annoying for everything”: public upload statistics indicate that >99% of workflows were upgraded seamlessly.
Of the workflows that are experiencing problems, the majority are of a shape that was already known to be problematic (reusable workflows), and a minority are of a new shape (stacking publish steps on top of each other). It’s worth noting that the top-level issue here is for the majority case, not the case you’re experiencing.
We’re going to improve the failure mode here as well (I’m going to be working on it in the coming days), but I don’t think there’s much value in overstating the case.
FWIW, this is because the steps within a single job on GitHub actions all share the same filesystem (and all other machine state). The filesystem only disappears in between jobs, because each job gets scheduled on its own VM.
I think @webknjaz has a fair point about public API surface here (and I’ll note that the change here isn’t intrinsically related to attestations; it’s just the first feature to surface it). At the same time, I think it’s unfortunate that we caused any degree of public workflow breakage here.
In the short term, you can work around this by setting
attestations: falseon the TestPyPI step – attestations don’t really matter for TestPyPI anyways, and that’ll prevent the file conflict. I’ll think some more about a longer-term solution tonight (I have ideas around enforcing domain separation between PyPI and TestPyPI artifacts that would potentially allow us to handle these kinds of cases).Maybe if we’d known before. But that ship has sailed. This wasn’t a public API change, so SemVer expectations don’t apply. You can clean the artifacts between the runs if you want, but that’s the extent of it. The validation exists to catch a security condition of accidentally leaving incorrect artifacts on disk produced by something outside the action invocation. And it did its job — it found misconfiguration. So it works as one would expect. The only action item I see is documenting this, as it’s probably not very obvious.
Just had this fail in Blinker (and if I had upgraded a bit sooner, it would have failed in Werkzeug and Flask too). It’s not directly related to the title of this issue, but further down it was indicated that uploading to test then pypi in the same workflow results in the error as well. Here’s the workflow run: https://github.com/pallets-eco/blinker/actions/runs/11746299115/job/32725793081?pr=176 It looks like it’s been fixed in twine and we’re just waiting for a release, and I’m going to try removing the test upload and re-running in the mean time. Nothing urgent, just wanted to add some extra data.
Is this something that can be fixed upstream in this action? I’m not really changing the default way this action works, just uploading to TestPyPI first, which I imagine should be a rather common thing to do.
If you have “upload to test pypi” then “upload to pypi” as sequential steps in a single job, as long as uploading to test pypi passes you won’t have time to verify it, it will move on to uploading to pypi. If uploading to test pypi fails, it would also fail on pypi, so you’re not gaining anything from the check.
If you want to use it as a true “upload to test, then check things before uploading to pypi”, then you would use two separate jobs, each with their own approval environment, which is exactly what the solution to this problem is too.
I was also in this camp (and may have unintentionally advocated it by using the pattern in Flask), but even before this issue I was starting to realize that it’s not actually helping the way I thought it was.
TestPyPI isn’t intended to be used in serial with PyPI – it’s an ephemeral index that you can use to test your workflows.
One common pattern I’ve seen with TestPyPI is to publish to it on
push: mainand similar events. But it’s generally not a good idea (IMO) to publish to it during normal release flows, since it’s not guaranteed to preserve account or package states (much less have any degree of uptime).In terms of resources:
@woodruffw do we want to keep producing the artifacts as outputs in the dist directory, provided we don’t currently set any outputs? If not, we could even go as far as writing them into a temporary directory instead of the workdir and then passing that to
twine uploadso they wouldn’t leak into the host filesystem. That’s what I mentioned to @facutuesca like 15 minutes ago on IRC… I just didn’t remember if we discussed files being “promised outputs” explicitly.I think we should make said warning very verbose and outline very specific steps to take to “migrate”. This would tie nicely with https://github.com/pypa/gh-action-pypi-publish/pull/305#issuecomment-2499315017, I imagine.
I’m not following how the ship has sailed, especially if it’s not a public API change.
I will say that if your goal here is to push attestations as a “good thing” for the ecosystem, then this problem goes against that goal, because from a high level, the appearance here is that things worked before attestations and they broke after attestations. It’s not a great feeling or a great look. Telling people that they now need to rewrite their complex workflows that used to work “just because” isn’t exactly meeting people where they are.
I freely admit I don’t understand how attestations work, and your description doesn’t even make sense to me (how does something get “left on disk” in a GitHub action? Aren’t github actions runs self contained?). But that’s the point. I’m sure most people are like me in that their eyes glaze over when faced with technical descriptions of why their GitHub Actions started breaking for no reason. It just feels like things used to work and now they don’t, and it’s clearly because of a change made in this repo, because they stopped working when dependabot updated this action.
I’m also getting the same
InvalidDistribution: Unknown distribution formattrying to upload the attestation to PyPI (but no such error to TestPyPI). https://github.com/data-apis/array-api-strict/actions/runs/11713859145/job/32627476623I don’t think I’m using a reusable workflow (that means it has
on: workflow_callin it, right?). https://github.com/data-apis/array-api-strict/blob/main/.github/workflows/publish-package.ymlNot really — there’s a long backlog and everybody wants to be escalated. It may take a long time to get your request reviewed. In general, we’re trying to emphasize that the PSF / PyPA needs funding to hire more people to go through that queue. I think one position has been funded for a year and that person is speeding up the process, but that’s probably not enough really. Ask your employer to fund another PyPI support person 😃
@webknjaz Thanks. I’ll review publishing workflow.
appreciate the quick look @woodruffw !
Thanks for the report. It would be useful to have a link to the log. And I even more useful if the job is restarted in debug mode. Meanwhile, we’ll have to wait for @woodruffw to see this and take a look from his side.