Skip to content

Simplify CreateProfile, fix bug filling list of profiles#6499

Open
evankanderson wants to merge 1 commit into
mindersec:mainfrom
evankanderson:cleanup-createprofile
Open

Simplify CreateProfile, fix bug filling list of profiles#6499
evankanderson wants to merge 1 commit into
mindersec:mainfrom
evankanderson:cleanup-createprofile

Conversation

@evankanderson

Copy link
Copy Markdown
Member

Summary

I was chasing a different bug, and noticed that CreateProfile was attempting to name unnamed profiles uniquely, but actually discarded the map of profile names. Testing for membership in a map will also be faster (and more correct) than repeated string.Contains. It turns out that some of the tests were also incorrect (wrong number of characters chopped), so fixed that as well.

Testing

Verified via unit tests.

@evankanderson evankanderson requested a review from a team as a code owner June 10, 2026 21:19
@coveralls

coveralls commented Jun 10, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 60.593% (-0.005%) from 60.598% — evankanderson:cleanup-createprofile into mindersec:main

@dakshhhhh16 dakshhhhh16 force-pushed the cleanup-createprofile branch from 9afd833 to 3b97ab4 Compare June 12, 2026 04:18

@krrish175-byte krrish175-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Clean fix for a real bug.

The old code allocated existingProfileNames as an empty slice and never populated it, so DeriveProfileNameFromDisplayName always saw zero existing names and the collision check was a no-op.

Switching from strings.Contains(strings.Join(...)) to a direct map lookup also fixes the false-positive substring matching problem (e.g. a derived name foo would have incorrectly collided with an existing profile named foobar).

The test string corrections (_when -> _whe) make sense since the 63-char limit truncates one character earlier than the old tests assumed.

@intelligent-ears

Copy link
Copy Markdown
Member

LGTM. The map lookup is correct and eliminates both the unpopulated slice bug and the substring false-positive. The test corrections for the 63-char truncation boundary make sense — the old tests were asserting wrong behavior

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.

5 participants