Skip to content

fix: don't dereference a nil release when the post-create lookup fails - #722

Open
NickJosevski wants to merge 1 commit into
mainfrom
nj/release-create-nil-lookup
Open

fix: don't dereference a nil release when the post-create lookup fails#722
NickJosevski wants to merge 1 commit into
mainfrom
nj/release-create-nil-lookup

Conversation

@NickJosevski

Copy link
Copy Markdown
Contributor

ReleaseService.GetByID returns (nil, err) on failure, but the warning branch after a successful release create read Assembled and ReleaseNotes off that nil result:

newlyCreatedRelease, lookupErr := octopus.Releases.GetByID(options.Response.ReleaseID)
if lookupErr != nil {
    cmd.PrintErrf("Warning: cannot fetch release details: %v\n", lookupErr)
    printReleaseVersion(options.Response.ReleaseVersion, newlyCreatedRelease.Assembled, ...)

So a transient server error in the window immediately after the release was created took the CLI down with a nil pointer dereference, instead of printing the warning that line was written to print. The release itself exists by that point, so the version still needs reporting.

Prints the version with empty details instead, and treats a nil release with no error as a lookup failure too.

Provenance

Pre-existing on main; found while reviewing #703 and originally fixed there. Lifting it into its own PR so it isn't gated on that stack, which isn't intended to merge as-is.

Verification

New release creation warns, rather than panicking, when the post-create lookup fails covers it: the post-create GET responds 500, and the command is expected to warn and still report the version. Confirmed it's a genuine regression test — reverting the create.go change makes it fail with panic: runtime error: invalid memory address or nil pointer dereference.

go build ./... clean, go test ./pkg/... green.

🤖 Generated with Claude Code

ReleaseService.GetByID returns (nil, err) on failure, so the warning
branch after a successful create panicked instead of printing the
warning: it read Assembled and ReleaseNotes off the nil result. A
transient server error immediately after the release was created took
the CLI down with a nil pointer dereference.

Print the version with empty details instead, and treat a nil release
with no error as a lookup failure too.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant