fix(match_spec)!: Make name in MatchSpec non-optional#2079
fix(match_spec)!: Make name in MatchSpec non-optional#2079KartikDua1504 wants to merge 24 commits intoconda:mainfrom
name in MatchSpec non-optional#2079Conversation
|
This change enforces that * is rejected in Strict mode (as tested in Rust). Should the Python bindings default to Lenient parsing (allowing globs), or should this be considered a breaking change in the Python API? |
There was a problem hiding this comment.
This does not need to be an Option anymore
There was a problem hiding this comment.
i would also assume that refactoring this to the end will lead to
rattler/crates/rattler_repodata_gateway/src/gateway/error.rs
Lines 52 to 54 in 3743acc
I think we should fail in |
|
Thanks for pointing these out! If it sounds good to you, I'd be happy to go ahead and work on removing those. Regarding the Python doctest, I'll hold off on making any changes there until you and @baszalmstra decide on the best path forward. Just let me know what direction you'd both prefer for the Python bindings, and I can update the PR accordingly |
In lenient mode, this should only succeed if globs are enabled through the constructor, otherwise fail. |
7c72962 to
be4c828
Compare
|
Kindly review the pull request. |
41bdb2b to
e51b468
Compare
|
I updated the PR accordingly. Just wanted to leave a quick note about some of the things i tweaked and if its okay. The Option wrapper in mod.rs : I updated the function name signature (dropping the Some()), but internally the core Matchspec struct defines the name field as an Option under the hood. Changing the core struct would be massive breaking API changes. |
e51b468 to
ff54e6f
Compare
This was the whole idea of #2039. we introduced |
Sure, I'll get to it then. |
…Option wrapper Previously, the `name` field in `MatchSpec` was wrapped in an `Option` as a workaround to support the nameless `*` wildcard. Since `*` can now be expressed properly through glob `PackageNameMatcher`s, this workaround is no longer necessary and adds redundant complexity. This commit removes the `Option` wrapper from the core `MatchSpec` struct, making `name` a guaranteed field, and implements the `Default` trait to automatically fallback to the `*` wildcard glob when a name is not explicitly provided. This required a workspace-wide architectural cleanup, including: - rattler_conda_types: Updated struct definitions, parsing logic, and formatting traits. - rattler_solve: Cleaned up `libsolv_c` and `resolvo` backends by removing redundant `if let Some(...)` and `.as_ref()` checks. - rattler_repodata_gateway & rattler_lock: Streamlined package matching and queries. - rattler (core): Updated installer logic. - py-rattler: Updated Python bindings to seamlessly handle the strict struct across the FFI boundary. - tests: Updated hundreds of assertions across all crates to remove obsolete `Some()` wrappers and `.unwrap()` calls.
…tream conflicts The test 'test_nameless_matchspec_error_without_url' is no longer valid since MatchSpec names now safely default to a '*' glob wildcard instead of throwing an error for being 'None'. Also removes leftover Option wrappers from recently merged upstream tests.
0740ce7 to
5ab6f3c
Compare
…od.rs and parse.rs
…od.rs and parse.rs
| fn matches(&self, spec: &MatchSpec) -> bool { | ||
| // Check if the name matches | ||
| if let Some(name) = &spec.name { | ||
| { | ||
| let name = &spec.name; | ||
| if !name.matches(&self.record().name) { | ||
| return false; | ||
| } | ||
| } |
|
Some checks are failing due to Network Errors, I think |
| @@ -63,7 +63,7 @@ impl PyMatchSpec { | |||
| /// The name of the package | |||
| #[getter] | |||
| pub fn name(&self) -> Option<PyPackageNameMatcher> { | |||
| .name | ||
| .as_ref() | ||
| .and_then(|n| Option::<PackageName>::from(n.clone())) | ||
| Some(&match_spec.inner.name).and_then(|n| Option::<PackageName>::from(n.clone())) |
Co-authored-by: Pavel Zwerschke <pavelzw@gmail.com>
Co-authored-by: Pavel Zwerschke <pavelzw@gmail.com>
Co-authored-by: Pavel Zwerschke <pavelzw@gmail.com>
pavelzw
left a comment
There was a problem hiding this comment.
for the next time, please go yourself through all changes in https://github.com/conda/rattler/pull/2079/changes, and think for each changed line: "is this line necessary? can it be made simpler?" if it is, change it.
this was definitely not the case in a lot of lines here.
i feel like i need to re-open a lot of comments because they were not actually addressed. i now pushed all changes myself to this branch as this was simpler than doing another round of reviews. the amount of time i needed to comment "this is not resolved yet" was way too many.
please also look at our AI Policy.
feel free to also let a second pair of eyes (i.e., a fresh session in your favorite agent) review the pr changes for irrelevant changes before submitting the fixes. it's frustrating for package maintainers to need to do this, especially with the rising quantity of ai-generated prs. the less unnecessary code i need to review, the better.
name in MatchSpec non-optional
|
I want to sincerely apologize for the frustration and extra work my recent commits caused you. I see now that I was rushing through the fixes which ended up wasting your time. That was definitely not my intention. I’ve taken your feedback to heart—especially regarding the 'AI-generated PR' quality and the need to manually review every single changed line for necessity before pushing. This has been a huge learning experience for me in terms of maintaining professional code quality and respecting the maintainer's review cycle. Thank you for stepping in to push the final fixes yourself to get this over the line. I’m going to be much more rigorous with my self-reviews moving forward to ensure I don't repeat these mistakes. I really appreciate your patience while I'm learning here. |
|
sorry but answering with an AI generated message on this is not respectful. |
|
denounce |
|
/recheck |
|
This PR has been automatically closed because the author is explicitly blocked in the vouch list. |
|
@pavelzw @baszalmstra |
Description
This PR updates the MatchSpec parser to handle the * package name as a native glob matcher (PackageNameMatcher::Glob) instead of silently dropping it to None.
This leverages the glob support recently added in PR #2036, which simplifies the mental model and allows us to remove legacy "if name.is_none()" checks throughout the codebase.
Changes made:
Removed the trimmed_package_name == "*" early-return hack in strip_package_name.
The * string now successfully falls through to PackageNameMatcher::from_str, which correctly identifies it as a Glob.
Fixes #2039
How Has This Been Tested?
I updated the existing tests and added new strict edge-case coverage:
Updated test_name_asterisk: Configured the parser options to allow globs (with_exact_names_only(false)) and asserted that the parsed name is now explicitly Some(PackageNameMatcher::from_str("*")) rather than None.
Added test_name_asterisk_edge_cases:
Verified the security boundary: Proved that running the parser in Strict mode correctly catches and blocks the * glob (throwing OnlyExactPackageNameMatchersAllowedGlob).
Verified complex parsing: Proved that a * glob parses flawlessly when buried inside a highly complex MatchSpec string with a channel, subdir, version, and build string.
AI Disclosure
Tools: Gemini 3.0 Pro (For generating edge cases of complex parsing, documentation, syntax correction.)
PROMPT : Generate a skeleton test in Rust for verifying complex string parsing and their edge conditions while using the '*' operator.
Checklist: