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

Detect Pants-generated lockfiles before attempting to validate. #17833

Merged
merged 1 commit into from Dec 17, 2022

Conversation

benjyw
Copy link
Sponsor Contributor

@benjyw benjyw commented Dec 17, 2022

Previously we would use the value of the python-only resolves_generate_lockfiles option to decide whether user lockfiles were expected to be Pants-generated, and therefore subject to validation, or not. And we would always validate tool lockfiles, which were expected to always be Pants-generated.

With this change, the lockfile parsing code raises a new exception subclass if the lockfile has no "Generated by Pants" header block. This allows us to differentiate between "this is a Pants-generated lockfile with invalid metadata", which remains an error, and "this is not Pants-generated at all", in which case we silently skip validating metadata.

The only case where this behavior is different from the previous behavior is if you had a lockfile that did have that header, but the user wanted Pants not to validate it, which is such a perversion of the intent of this feature (which is to support lockfiles generated manually using pex or poetry) that I see no need to worry about it.

This is part of a sequence of planned changes to unify tool and user lockfiles into a single mechanism.

Previously we would use the value of the python-only
resolves_generate_lockfiles option to decide whether user
lockfiles were expected to be Pants-generated, and therefore
subject to validation, or not. And we would always validate
tool lockfiles, which were expected to always be Pants-generated.

With this change, the lockfile parsing code raises a new exception
subclass if the lockfile has no "Generated by Pants" header block,
This allows us to differentiate between "this is a Pants-generated
lockfile with invalid metadata", which remains an error, and
"this is not Pants-generated at all", in which case we silently
skip validating metadata.

The only case where this behavior is different from the previous
behavior is if you had a lockfile that did have that header, but
the user wanted Pants not to validate it, which is such a perversion
of the intent of this feature (which is to support lockfiles generated
manually using pex or poetry) that I see no need to worry about it.

This is part of a sequence of planned changes to unify tool and
user lockfiles into a single mechanism.
@benjyw
Copy link
Sponsor Contributor Author

benjyw commented Dec 17, 2022

I set this label to "user-api-change" because of that extremely unlikely perverse case, but could also just go with "internal".

Copy link
Member

@jsirois jsirois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. I'd leave this user api labelled. It allows scie-pants, as a user, to know it can kill a config setting; so it affects users.

@benjyw benjyw merged commit ee596bd into pantsbuild:main Dec 17, 2022
@benjyw benjyw deleted the detect_non_pants_lockfiles branch December 17, 2022 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants