-
Notifications
You must be signed in to change notification settings - Fork 0
fix(wfctl): pin plugin install to requested version, not stale manifest #426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -116,7 +116,7 @@ func runPluginInstall(args []string) error { | |||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| nameArg := fs.Arg(0) | ||||||||||||||||
| rawName, _ := parseNameVersion(nameArg) | ||||||||||||||||
| rawName, requestedVersion := parseNameVersion(nameArg) | ||||||||||||||||
| pluginName := normalizePluginName(rawName) | ||||||||||||||||
|
|
||||||||||||||||
| cfg, err := LoadRegistryConfig(*cfgPath) | ||||||||||||||||
|
|
@@ -165,6 +165,14 @@ func runPluginInstall(args []string) error { | |||||||||||||||
|
|
||||||||||||||||
| fmt.Fprintf(os.Stderr, "Found in registry %q.\n", sourceName) | ||||||||||||||||
|
|
||||||||||||||||
| // Pin the manifest to the requested version when it differs from what the registry has. | ||||||||||||||||
| // The registry manifest may be stale (e.g. v0.1.0) while the user requests v0.2.1. | ||||||||||||||||
| // pinManifestToVersion rewrites download URLs in-place so the right release is fetched. | ||||||||||||||||
| registryVersion := manifest.Version | ||||||||||||||||
| if requestedVersion != "" && requestedVersion != manifest.Version { | ||||||||||||||||
| pinManifestToVersion(manifest, requestedVersion) | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| // Resolve and install dependencies before installing the plugin itself. | ||||||||||||||||
| if len(manifest.Dependencies) > 0 { | ||||||||||||||||
| resolved := make(map[string]string) | ||||||||||||||||
|
|
@@ -174,6 +182,10 @@ func runPluginInstall(args []string) error { | |||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| if err := installPluginFromManifest(pluginDirVal, pluginName, manifest); err != nil { | ||||||||||||||||
| if requestedVersion != "" && requestedVersion != registryVersion { | ||||||||||||||||
| return fmt.Errorf("requested version %s not available for %q (registry manifest is at %s): %w", | ||||||||||||||||
|
||||||||||||||||
| return fmt.Errorf("requested version %s not available for %q (registry manifest is at %s): %w", | |
| return fmt.Errorf("failed to install requested version %s for %q (registry manifest is at %s): %w", |
Copilot
AI
Apr 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pinManifestToVersion won’t rewrite version strings in the filename when the URL already matched the /releases/download/<old>/ pattern. For URLs like .../releases/download/v0.1.0/plugin-v0.1.0.tar.gz, the path gets updated but the filename remains at the old version, so the download can still 404 or fetch the wrong asset. Apply the second replacement against the already-rewritten URL (or check strings.Contains(rewritten, oldVersion)), not only when rewritten == url.
| // If the version string also appears in the filename, rewrite that too. | |
| if rewritten == url && oldVersion != "" { | |
| rewritten = strings.ReplaceAll(url, oldVersion, requestedVersion) | |
| // If the version string also appears elsewhere in the URL (for example, | |
| // in the asset filename), rewrite that too using the already-updated URL. | |
| if oldVersion != "" { | |
| rewritten = strings.ReplaceAll(rewritten, oldVersion, requestedVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When version pinning is active, all manifest SHA256 values are cleared, which means the download step will silently skip checksum verification for the pinned install. Consider emitting a clear warning (or failing unless a checksum for the requested version can be obtained) so users understand they’re installing without integrity verification in this path.