Prevent delete_collections from removing localized configured collections - #3532
Prevent delete_collections from removing localized configured collections#3532antwanchild wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a delete_collections false-positive deletion scenario when library operations run before collections: configured collections whose current Plex titles are localized (or come from custom name overrides/template expansion) are now recognized as configured and retained.
Changes:
- Added configured-collection name alias resolution that accounts for mapping names, explicit/custom names, English translations, and selected-language translations (including template-variable substitution).
- Updated
delete_collectionsconfigured-name precheck to use the expanded alias set per collection file entry. - Added focused unit tests for multi-language alias resolution behavior and updated the changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
modules/operations.py |
Adds name-alias resolution helpers and uses them to prevent deleting localized/custom-titled configured collections before the collection builder runs. |
tests/test_operations.py |
Adds test coverage for alias resolution across languages, custom overrides, and dynamic collection data. |
CHANGELOG.md |
Documents the bug fix under Fixed. |
Suppressed comments (1)
modules/operations.py:127
limitis treated as falsy, so a validlimit: 0(or any falsy numeric limit) would be dropped and<<limit>>would not be substituted. This can break configured-name alias matching for templates that include<<limit>>.
translation_key = str(data[methods["translation_key"]]) if "translation_key" in methods and data[methods["translation_key"]] else None
key_name = str(data[methods["key_name"]]) if "key_name" in methods and data[methods["key_name"]] else None
limit = data[methods["limit"]] if "limit" in methods and data[methods["limit"]] else None
translation_prefix = str(data[methods["translation_prefix"]]) if "translation_prefix" in methods and data[methods["translation_prefix"]] else ""
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
badja-dev
left a comment
There was a problem hiding this comment.
Close to mergeable. The fix correctly generalises the earlier English-only translation workaround (#3168) into a full alias resolver that mirrors CollectionBuilder's real template/language resolution logic (confirmed against modules/builder.py's own template and language handling), it's well covered by new tests, and CI is fully green
The new alias resolution now runs unconditionally whenever any collection operation is enabled, not just when delete_collections.configured is actually in use, which is a behavior change beyond what the PR describes. One minor cleanup item (dead code) is not blocking
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
dbb02c1 to
d31592b
Compare
What type of PR is this?
Description
This PR prevents
delete_collectionsfrom deleting configured collections whose current Plex titles are localized or produced by a custom name override when operations run before collections.The fix is not specific to French. It reads the selected language from each collection file or collection-level override, validates it against Kometa's supported translation keys, and resolves that language dynamically. If a particular collection has no name in the selected translation, its English name remains a safe fallback.
With
configured: false,managed: true, andlanguage: fr, the supplied reproduction compared a French Plex title such asCollections Classementonly against the English mapping nameChart Collections. The title was classified as unconfigured, deleted, and recreated later in the same run.When
delete_collections.configuredis set, the configured-name precheck expands the collection's name-related template attributes without constructing a collection or calling Plex. It treats every supported representation as an alias for the same configured collection. The originalif configured is not None:guard remains in place, so reporting, asset-only, and other collection operations do not trigger template or translation resolution.Observed impact
The supplied 28,545-line debug log showed 54 configured collections deleted and recreated: 30 movie collections and 24 show collections.
Chart CollectionsCollections ClassementTMDb Popular🌍 Films populaires dans le mondeStreaming CollectionsCollections DiffusionApple TV MoviesFilms de Apple TVGenre CollectionsCollections GenreAction MoviesAction FilmsEvery unique deleted title in the log subsequently appeared as a collection's resolved final name.
Configured-name aliases
Chart Collections🌍 Films populaires dans le mondename_*,name_format, and direct name overridesChart CollectionsCollections ClassementThe resolver works on a deep copy of collection data, so the deletion precheck does not mutate the definition that will later be used by
CollectionBuilder. A failure resolving one collection is isolated to that collection and logged at debug level.Language coverage
translation_keysValidation
configured is not Noneresolution guardgit diff --checkaspellis unavailableRelated Issues [optional]
Have you updated the Documentation to reflect changes (if necessary)?
This corrects internal configured-name matching; no configuration attributes or user workflows changed.
Have you updated the JSON Schema files (if necessary)?
No supported attributes, accepted values, or configuration structures changed.
Have you updated the CHANGELOG.md?