fix: report unknown release versions instead of a server null reference - #696
Draft
NickJosevski wants to merge 1 commit into
Draft
fix: report unknown release versions instead of a server null reference#696NickJosevski wants to merge 1 commit into
NickJosevski wants to merge 1 commit into
Conversation
`release deploy` passed --version straight to the executions API, which answers an unknown version with "Object reference not set to an instance of an object". Resolve the release before deploying so a version that doesn't exist is reported by name, and call out `latest` explicitly since it is not a supported alias. Refs #294 Co-Authored-By: Claude Opus 5 (1M context) <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.
Refs #294
Root cause
octopus release deploy --version latest(or any version that doesn't exist) sends the literal string straight through to the executions API:deployRun→executor.releaseDeploy→POST /api/{space}/deployments/create/untenanted/v1withReleaseVersion: "latest".In automation mode (
--no-prompt) nothing on the client ever looks the release up, so the server is left to resolve a release namedlatest, finds none, and NREs. The CLI faithfully prints what it got back:That's the bug benPearce1 confirmed in the issue. This PR fixes that half. The
latestfeature itself is not implemented here — see Open questions below.What changed
New
selectors.FindRelease(pkg/question/selectors/releases.go) — sits alongside the existingFindProject/FindChannel/FindRunbookhelpers and wrapsreleases.GetReleaseInProject, turning "no such release" into a message that names what was asked for:and, for the literal
latest, one that says why and what to do instead:Two not-found shapes are handled: a 404 carrying an
APIErrorbody, and a 404 with an empty body — the latter doesn't reachgo-octopusdeploy's error path at all, it decodes into a zero-valuedRelease, so the empty ID is checked as well. Any other error (403, 500, transport) is returned untouched, so the server stays the authority on things like permissions.release deployautomation path now resolves the release after resolving the project, before building the deployment command. Side benefit:options.ReleaseIDis populated up front, so the two extra lookups that used to happen after deploying just to print the "View this release" link are gone. Net API calls: unchanged for table output, +1 for--output-format basic|json.release deployinteractive path now goes through the same helper, so a bad--versiongets the same message instead of dereferencing an empty release and failing later on a channel lookup.release progression allow/prevent—progression/shared.FindReleasenow delegates to the new selector rather than duplicating the lookup with a different message.Test evidence
Added two cases to
TestDeployCreate_AutomationMode, one per not-found shape:release deploy reports a release version that doesn't exist— 404 with anAPIErrorbodyrelease deploy explains that 'latest' is not a supported release version— 404 with an empty bodyExisting automation tests were updated for the new pre-flight lookup (added expectation) and the removed post-deploy lookups.
go vet ./pkg/...reports only the four pre-existingunreachable codefindings inworker/shared,workerpool/shared, andtenant/variables/list.Open questions / options — needs a maintainer call
benPearce1 called dropping
latestintentional ("could mean latest by time or latest by semver"); DamienDaco wants the oldoctobehaviour back to deploy the newest release. That's a product decision, so this PR deliberately stops at the error message and leaveslatestunimplemented. The three ways forward:(a)
--version latest= most recently created release (byAssembleddate). Matches oldocto, zero new flags, drops straight into existing CI scripts. Costs: re-introduces exactly the ambiguity that motivated the removal, and quietly disagrees with a user who assumed semver — for a release with a version prefix scheme or an out-of-order rebuild, "newest by time" and "highest by semver" are different releases, and the command that deploys the wrong one gives no hint. Also collides with a real release literally namedlatest(rare, but the alias would win). Currently the error message tells users this alias doesn't exist; implementing (a) makes that message wrong, so it has to land as one change.(b) An explicit modifier, e.g.
--latest-by time|semver(mutually exclusive with--version). No ambiguity, self-documenting in--help, and the two meanings stay separately addressable. Costs: new flag surface on an already wide command; needs a decision on whether it also applies torunbook run, and on whether--channelshould scope it (deploying "the latest release" usually means "latest in this channel" —GetReleasesInProjectChannelalready exists for that).(c) Ship nothing beyond this error fix. The message now names the project and points at
octopus release list, so the failure is self-service. Scripts that want the newest release can do it explicitly today withoctopus release list -p MyProject -f json.Recommendation: (b), scoped to
release deployfirst, with--latest-by semverand--latest-by timeboth spelled out, optionally narrowed by--channel. It gives DamienDaco the capability without re-introducing the ambiguity that gotlatestremoved, and it degrades honestly — a user who picks the wrong ordering picked it explicitly. If parity withoctomatters more than precision, (a) is a much smaller change and I'm happy to swap. Either way thelatestbranch ofreleaseNotFoundErrorgets deleted as part of implementing it.Happy to implement whichever you pick in this PR.
🤖 Generated with Claude Code