Skip to content

Conversation

jobama7860
Copy link

Add nil check for lastPromo in buildTargetFreightCollection method to prevent panic when accessing FreightCollection on stages with no previous promotions. The panic occurred when stage.Status.LastPromotion was nil, but the code attempted to access lastPromo.Status without checking if lastPromo itself was nil first.

Fixes promotion controller panics with error:
"runtime error: invalid memory address or nil pointer dereference"

Changes:

Add nil check for lastPromo before accessing its Status field Add additional safety check for FreightCollection.Freight map Maintain existing functionality while improving robustness

Signed-off-by: Joe Brown [email protected]

Screenshot 2025-08-20 at 8 56 38 AM

Add nil check for lastPromo in buildTargetFreightCollection method to prevent panic when accessing FreightCollection on stages with no previous promotions.
The panic occurred when stage.Status.LastPromotion was nil, but the code attempted to access lastPromo.Status without checking if lastPromo itself was nil first.

Fixes promotion controller panics with error:
"runtime error: invalid memory address or nil pointer dereference"

Changes:

Add nil check for lastPromo before accessing its Status field
Add additional safety check for FreightCollection.Freight map
Maintain existing functionality while improving robustness

Signed-off-by: Joe Brown <[email protected]>
@jobama7860 jobama7860 requested a review from a team as a code owner August 20, 2025 14:28
Copy link

netlify bot commented Aug 20, 2025

Deploy Preview for docs-kargo-io canceled.

Name Link
🔨 Latest commit 5fdde20
🔍 Latest deploy log https://app.netlify.com/projects/docs-kargo-io/deploys/68a5db973af7b00008d0cdb1

@krancour
Copy link
Member

Why did you create six different PRs for this one change and close the other five?

Please don't make a mess out of our issue/PR queues.

Copy link
Member

@fuskovic fuskovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see a test added for this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants