is_compatible_version returns None for malformed sublime_text ranges; release silently dropped
A malformed sublime_text range in a repository release makes is_compatible_version() return None, and the release is silently skipped as "incompatible" instead of raising an invalid-key error.
selectors.is_compatible_version documents True if compatible version, False otherwise, but it falls through to an implicit return None for anything that isn't one of exactly four shapes, and the regexes are whitespace- and format-sensitive. Verified live against the Package Control 4.x currently loaded in Sublime Text 4 (st_version=4200):
sublime_text value |
result |
|---|---|
"3000 - 4000" |
False (correct) |
"3000-4000" |
None |
">= 3000" |
None |
">=3000 " (trailing space) |
None |
" *" |
None |
"4200" |
None |
">=3000,<4200" |
None |
">=3092" |
True |
In json_repository_provider.py (three places) the value is first validated as a str (InvalidPackageReleaseKeyError / InvalidLibraryReleaseKeyError otherwise) but then only if IS_ST and not is_compatible_version(value): continue, so a typo such as "3000-4000" or a stray space is treated exactly like "this release is for another ST version". The release (or the entire package, if it's the only one) silently disappears for every user of that repository/channel, with no message to the repository author or in the console, even though the very same code path raises a clear error for a non-string value.
Suggested fix: have is_compatible_version raise ValueError for unrecognised expressions (and tolerate surrounding whitespace / >= 3000 / 3000-4000 if desired), and let the provider translate that into InvalidPackageReleaseKeyError/InvalidLibraryReleaseKeyError, or at least log a warning. At minimum make it return False as documented.
Checked against current master (1c52ef1): selectors.is_compatible_version is unchanged, and package_registry.py (lines ~410 and ~447, and is_compatible_version(release["sublime_text"])) and package_manager.py:402 use the falsy result the same way, so a malformed range still silently makes a release "incompatible". (The json_repository_provider.py locations quoted above moved into the registry in that refactor.) Same for the two other items I filed: #1759 (version_match_prefix('release-', 'release-') still raises IndexError on master) and #1760/#1761 (pep440.py is byte-identical to the 4.2.8 release).
Returning None and dropping invalid releases is more or less expected and no debug messages are planned, mainly because major source of packages is a curated and validated main index. Anything 3rd-party or custom repositories failing is expected and accepted.