Skip to content
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

Warn/Deprecate when hash is provided in constraints file #12956

Open
1 task done
notatallshaw opened this issue Sep 5, 2024 · 0 comments
Open
1 task done

Warn/Deprecate when hash is provided in constraints file #12956

notatallshaw opened this issue Sep 5, 2024 · 0 comments
Labels
C: error messages Improving error messages state: needs discussion This needs some more discussion type: deprecation Related to deprecation / removal.

Comments

@notatallshaw
Copy link
Member

notatallshaw commented Sep 5, 2024

What's the problem this feature will solve?

It appears hashes in constraint files only enforce hashes in requirement files and the behaviour of if they are different in constraint files vs. requirement files is not well defined.

Many scenarios of why they would be useful in a constraint file (such as pinning requirements or build requirements) do not seem possible because they also need to be in the requirements file, e.g.

  1. Create constraints.txt with the contents:
setuptools==74.1.1 --hash=sha256:fc91b5f89e392ef5b77fe143b17e32f65d3024744fba66dc3afe07201684d766
  1. Run pip install setuptools==74.1.1 -c constraints.txt, and get error:
ERROR: Hashes are required in --require-hashes mode, but they are missing from some requirements. Here is a list of those requirements along with the hashes their downloaded archives actually had. Add lines like these to your requirements files to prevent tampering. (If you did not enable --require-hashes manually, note that it turns on automatically when any package has a hash.)
    setuptools==74.1.1 --hash=sha256:fc91b5f89e392ef5b77fe143b17e32f65d3024744fba66dc3afe07201684d766

I think the fact that hashes are accepted in constraint files leads users to believe that requirements or build requirements will be "constrained" to those hashes, and this error isn't very clear, it says the requirement requires a hash and then shows it having a hash, leading to a lot of effort by users to find out this isn't the case.

Describe the solution you'd like

When a hash is specified in the constraint file, log a warning or a deprecation warning.

Alternative Solutions

Maybe there is some useful use case I am missing and this shouldn't be done?

Additional context

Example of spending a lot of time finding out expected behaviour doesn't work: #12942

Code of Conduct

@notatallshaw notatallshaw added type: feature request Request for a new feature S: needs triage Issues/PRs that need to be triaged state: needs discussion This needs some more discussion type: deprecation Related to deprecation / removal. C: error messages Improving error messages and removed type: feature request Request for a new feature S: needs triage Issues/PRs that need to be triaged labels Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: error messages Improving error messages state: needs discussion This needs some more discussion type: deprecation Related to deprecation / removal.
Projects
None yet
Development

No branches or pull requests

1 participant