Auto-remove addons from bundle if they were removed - #1102
martastain wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new cleanup block currently catches overly broad exceptions and can mis-handle malformed/None addon data, potentially masking real failures or raising at runtime.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR improves robustness of update_bundle by cleaning up bundle addon entries that no longer exist in AddonLibrary, so bundles can still be archived/updated even after an addon/version has been removed from the server.
Changes:
- Validate existing bundle
data["addons"]againstAddonLibraryduringupdate_bundle. - Automatically remove missing addons/versions from the bundle and log a warning.
File summaries
| File | Description |
|---|---|
| api/bundles/bundles.py | Adds pre-validation/cleanup of persisted bundle addons before running bundle validation and applying patches. |
Review details
Suppressed comments (1)
api/bundles/bundles.py:268
- Catching
Exceptionhere will also swallow unexpected failures inside addon loading/initialization and silently mutate the bundle, which can hide real problems. SinceAddonLibrary.addon()documents raisingNotFoundExceptionfor missing addons/versions, catch that specific exception (and handleNoneversions explicitly) to avoid masking unrelated errors.
for addon_name, addon_version in list(addons.items()):
try:
_ = AddonLibrary.addon(addon_name, addon_version)
except Exception:
logger.warning(
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
How is this supposed to be working? Removed addon (server) (without restart), I can still select him in the Bundle addon version dropdown (which is I guess expected). But when I select it, it seems it gets saved ok. I created new copy of bundle, selected that missing addon and saved it fine. (But updated method is probably not called, but (After server restart addon version gets removed in the bundle. If that is new expected behavior, then it work :).) |
There was a problem hiding this comment.
🟡 Changes recommended
The new addon pre-validation can incorrectly remove valid project-bundle placeholder versions (e.g. __inherit__ / __disable__) because they are not real addon versions and will always fail AddonLibrary.addon() lookups.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved validation and cache-handling issues remain for patched references and addon placeholders.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (2)
api/bundles/bundles.py:393
- This validation covers only the stored
data["addons"]; the patch loop below checks only that the addon name exists and then accepts any semver-shaped but unavailable version. Withforce=True,check_bundleis skipped and that invalid patched version is persisted, so the new cleanup does not cover all addons being saved. Validate the merged addon map (or calladdon_library.addonhere, while honoring the placeholder values) before writing it.
addon_definition = addon_library.get(addon_name)
if addon_definition is None:
logger.warning(f"Addon {addon_name} does not exist, ignoring")
continue
api/bundles/bundles.py:314
- The new installer/dependency checks sanitize only values read from
data, but laterpatch.installer_versionandpatch.dependency_packagesare assigned directly. A PATCH can therefore reintroduce a deleted installer or dependency reference (andcheck_bundledoes not validate these files), leaving invalid references persisted; validate the post-patch values before constructing the saved data.
existing_dependency_packages = await list_dependency_packages()
for platform, filename in list(dependency_packages.items()):
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Lite
| # Project bundle placeholders (and disabled addons) are not real versions. | ||
| # Only validate addon existence in that case. | ||
| if addon_version in (None, "__inherit__", "__disable__"): |
|
|
||
| if patch.is_production is not None or patch.is_staging is not None or patch.addons: | ||
| await AddonLibrary.clear_addon_list_cache() | ||
| await addon_library.clear_addon_list_cache() |
This pull request adds validation to the handling of addons in the
update_bundlefunction. Now, before updating a bundle, the code checks that each addon listed actually exists in theAddonLibrary. If an addon does not exist, it is removed from the bundle and a warning is logged. This helps prevent invalid or non-existent addons from being saved in the bundle.(And most importantly - it gives back the ability to archive/change bundles, when they contain an addon that was removed, because originally, this triggered an error during bundle validation)