Skip to content

fix(validation): reject nil samples before applying stack limits - #6130

Open
Vanshul97 wants to merge 1 commit into
grafana:mainfrom
Vanshul97:fix/validate-profile-nil-sample
Open

Vanshul97 wants to merge 1 commit into
grafana:mainfrom
Vanshul97:fix/validate-profile-nil-sample

Conversation

@Vanshul97

Copy link
Copy Markdown

ValidateProfile applies the stack depth and sample label limits by reading each sample's fields before it checks for nil samples. With either limit set, a profile containing a nil sample panics with a nil pointer dereference instead of returning the MalformedProfile "nil sample" error that the later check was meant to produce.

This moves the nil check into the first loop over samples and removes the now-redundant one.

Tested: added a case to TestValidateProfile with a nil sample and non-zero depth and label limits. It panics without the change and passes with it. go test -race ./pkg/validation/ passes.

ValidateProfile dereferenced each sample to apply the stack depth and
sample label limits before the nil sample check ran, so a profile with a
nil sample panicked instead of returning a MalformedProfile error when
either limit was set. Move the nil check into the first loop.
@cla-assistant

cla-assistant Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cla-assistant

cla-assistant Bot commented Nov 23, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@cla-assistant

cla-assistant Bot commented Nov 23, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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