[bugfix] repo:install-and-deploy respect explicitly-requested version#6433
Open
joewiz wants to merge 1 commit into
Open
[bugfix] repo:install-and-deploy respect explicitly-requested version#6433joewiz wants to merge 1 commit into
joewiz wants to merge 1 commit into
Conversation
When a higher version of a package is already in the EXPath registry, calling repo:install-and-deploy(name, "<lower>", url) would correctly fetch the requested XAR and install it into the registry, but the subsequent deploy() step would re-resolve by name via packages.latest() and deploy the existing higher version's directory instead. The user sees a successful "ok" status, but the deployed application is the higher version, not the one they asked for. Two changes: 1. Deployment.deploy(...) now has a Package-based overload that takes the freshly-installed Package directly. The by-name overload is kept and delegates to the new one via getPackage(pkgName, repo). 2. installAndDeploy(...) looks up the package by the version extracted from the XAR descriptor (via Packages.version(...)) and passes it to the Package-based deploy overload, bypassing packages.latest(). Includes XQSuite regression test (deploy:install-lower-version-after-higher): install 1.0.0, then install 0.5.0 over it, and verify the deployed expath-pkg.xml in the target collection is 0.5.0's, not 1.0.0's. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[This PR was co-authored with Claude Code. -Joe]
Summary
When a higher version of a package is already installed in the EXPath registry, calling
repo:install-and-deploy($name, $version, $url)with an explicit lower$versionreports success but silently deploys the existing higher version instead of the one the user asked for. This PR makes the deploy step use the freshly-installed package directly, so the explicit version request is honored.This was surfaced by Craig Berry on Slack while attempting to downgrade
tei-publisher-libfrom 6.1.0 to 6.0.2. A companion fix for the related silent-failure onrepo:removeis in #6432.What changed
exist-core/src/main/java/org/exist/repo/Deployment.javaPackage-based overloaddeploy(DBBroker, Txn, Package, String). The body is the priordeploy(... String pkgName, Optional<ExistRepository> repo, ...)lifted to take aPackagedirectly, so the package-dir / abbrev / version lookups all flow from one consistent source instead of re-resolving by name halfway through.repo:deploy(name)callers) and delegates to the new one viagetPackage(pkgName, repo).installAndDeploy(...)now resolves the just-installed package by the version extracted from the XAR descriptor (Packages.version(requestedVersion)) rather than relying on whatinstallPackage()returns — which, for the higher-version-already-present case, waspackages.latest(). The lookup is in a smallresolveInstalledVersion()helper to keepinstallAndDeploy's NPath complexity at its prior level.extensions/modules/expathrepo/src/test/xquery/modules/expathrepo/deployment.xqldeploy:install-lower-version-after-higher: installs version 1.0.0, then installs version 0.5.0 (using fresh fixtures with namehttp://exist-db.org/apps/dtest-versioningto avoid polluting other tests), and asserts that theexpath-pkg.xmlwritten to the deployed target collection/db/apps/dtest-versioning/reports version 0.5.0. Before the fix this returned 1.0.0.doc("/db/apps/<target>/expath-pkg.xml")rather thanrepo:get-resource(name, "expath-pkg.xml")— the latter returns frompackages.latest()'s repo dir and so reports 1.0.0 even after a correct deploy of 0.5.0; only the deployed target collection shows what was actually delivered to the user.Root cause
In
Deployment.installAndDeploy:repo.getParentRepo().installPackage(xar, ...)is called, which installs the XAR into the registry and returns somePackage— but for an EXPath name with multiple versions present, it returnspackages.latest(), not necessarily the just-installed one.deploy(pkgName, ...)then callsgetPackage(pkgName, repo), which also returnspackages.latest(), and deploys from that package's dir.So even though the right XAR was unpacked into
data/expathrepo/<abbrev>-<requested>/, the deploy step copies files out ofdata/expathrepo/<abbrev>-<latest>/into/db/apps/<target>/. Result: install OK, but deploy installs the wrong version, with no error.Test plan
mvn test -pl extensions/modules/expathrepo -Dtest='ExpathRepoTests'— 9/9 pass (8 prior + new regression)cleanup()unused, parameter reassignment warnings are pre-existing on this file)repo:install-and-deploy(name, "0.5.0", url)against local copy of the XAR) — before this commit, deployedexpath-pkg.xmlreports 1.0.0; after, 0.5.0.Related
repo:removereturningfalsewith no diagnostic✔︎ uninstalled