Skip to content

fix: avoid silently aborting profile init on single entity marshalling error#6331

Merged
evankanderson merged 1 commit intomindersec:mainfrom
AftAb-25:fix/6330-profile-init-silent-loop-abort
Apr 11, 2026
Merged

fix: avoid silently aborting profile init on single entity marshalling error#6331
evankanderson merged 1 commit intomindersec:mainfrom
AftAb-25:fix/6330-profile-init-silent-loop-abort

Conversation

@AftAb-25
Copy link
Copy Markdown
Contributor

Description

This PR fixes a bug in the profile initialization flow where a single entity's parsing/marshalling issue could completely stop the rest of a project's entities from being evaluated against a new profile.

In internal/reconcilers/run_profile.go, publishProfileInitEvents loops over all registered entities for a project. Previously, if entRefresh.ToMessage(m) failed inside that loop, the code returned nil. This silently exited the entire function, abandoning all remaining entities in the slice. From the caller's perspective (handleProfileInitEvent), the function returned successfully, so no retries were triggered and nothing was visibly wrong except that some entities were randomly skipped during profile initialization.

Change:

Instead of return nil, this simply logs the error and uses continue to move on to the next entity in the loop.

Fixes #6330

Checklist

  • Includes tests for the changes
  • Code compiles cleanly
  • Documentation updated (if applicable)

…rofileInitEvents

When entRefresh.ToMessage() fails for a single entity inside the
profile init event loop, the code used to return nil which silently
aborted the entire loop. Any entities after the failed one would
never get their profile init events published, and the caller would
see no error indicating that entities were skipped.

Change return nil to continue so that a single entity's marshalling
failure is logged and skipped, while the remaining entities still
get their refresh events published as expected.

Fixes mindersec#6330
@AftAb-25 AftAb-25 requested a review from a team as a code owner April 10, 2026 15:34
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 59.507% (+0.002%) from 59.505% — AftAb-25:fix/6330-profile-init-silent-loop-abort into mindersec:main

Copy link
Copy Markdown
Member

@evankanderson evankanderson left a comment

Choose a reason for hiding this comment

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

I don't see any way to test this, as the only error that can be triggered is from json.Marshal() on HandleEntityAndDoMessage, which is a struct with simple fields and tags.

I'm willing to approve this, but it's not really a likely bug fix. (If the go allocator fails for json.Marshal(), we're unlikely to make further progress. Similarly, if the descriptor for HandleEntityAndDoMessage gets corrupted in-memory, we've got a bad enough day that this isn't going to save 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.

Bug: [publishProfileInitEvents] silently drops profile init events for remaining entities on marshalling error

3 participants