Skip to content
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

fix: fix miss makezero bug #4268

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alingse
Copy link

@alingse alingse commented May 26, 2024

What this PR does / why we need it:

Fixes #

I was running github actions to run linter makezero for top github golang repos.

see issues alingse/go-linter-runner#1

and the github actions output

https://github.com/alingse/go-linter-runner/actions/runs/9242655147/job/25425748900

====================================================================================================
append to slice `tags` with non-zero initialized length at https://github.com/m3db/m3/blob/master/src/dbnode/integration/integration_data_verify.go#L241:11
====================================================================================================

but the linter can't find the make(sort.StringSlice, len(*t)) so not reported in the actions output

Special notes for your reviewer

this is not cause a real bad bug because the []string was sort and finally called by WriteString(s)

so the empty value string was save in the slice but ignored when called by WriteString

func (r *result) genID() result {
	tags := make(sort.StringSlice, 0, len(r.Metric))
	for k, v := range r.Metric {
		tags = append(tags, fmt.Sprintf("%s:%s,", k, v))
	}

	sort.Sort(tags)
	var sb strings.Builder
	// NB: this may clash but exact tag values are also checked, and this is a
	// validation endpoint so there's less concern over correctness.
	for _, t := range tags {
		sb.WriteString(t) // this ignore the empty string t
	}

Does this PR introduce a user-facing and/or backwards incompatible change?:

NONE

Does this PR require updating code package or user-facing documentation?:


@CLAassistant
Copy link

CLAassistant commented May 26, 2024

CLA assistant check
All committers have signed the CLA.

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.

3 participants