Skip to content

fix: prevent silent loop aborts during profile initialization#6352

Closed
AftAb-25 wants to merge 2 commits intomindersec:mainfrom
AftAb-25:fix/6351-reconciler
Closed

fix: prevent silent loop aborts during profile initialization#6352
AftAb-25 wants to merge 2 commits intomindersec:mainfrom
AftAb-25:fix/6351-reconciler

Conversation

@AftAb-25
Copy link
Copy Markdown
Contributor

Summary

This PR fixes a critical data starvation flaw in the Reconciler where a single broken entity payload would prematurely abort the profile initialization loop for the rest of a project.

Currently in internal/reconcilers/run_profile.go, when publishProfileInitEvents iterates through a project's entities to evaluate a new profile, it builds a refresh message payload using entRefresh.ToMessage(m). If that single payload fails to marshal, the reconciler simply hits return nil.

Returning nil instantly aborts the entire for loop, meaning any remaining repositories or artifacts in the project are silently discarded and never evaluated against the new profile rules. Worse, it causes the event router to ACK the payload as successful, so it is never retried.

Changes

  1. Swapped the hard return nil with a graceful continue inside the error block so the engine cleanly logs the specific entity's marshaling error and naturally continues querying the rest of the project's repositories.
  2. Added a test (skip entity on marshal error) in run_profile_test.go that explicitly simulates a marshaling failure mid-batch to guarantee downstream entities continue processing unhindered.

Fixes #6351

Checklist

  • Code compiles cleanly
  • Includes tests for the changes (existing tests pass)

@AftAb-25 AftAb-25 requested a review from a team as a code owner April 12, 2026 19:22
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 59.39%. remained the same — AftAb-25:fix/6351-reconciler 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.

It appears that the current error handling code is effectively unreachable (we're marshalling a watermill Message with a UUID and an empty payload -- the only time this should fail is if something is seriously wrong in json.Marshal, probably due to memory corruption).

I'm not sure that the "fix" here is worth the cost -- especially since the switch from return nil to continue seems to have already merged.

@evankanderson
Copy link
Copy Markdown
Member

(This was fixed in #6331 )

@evankanderson
Copy link
Copy Markdown
Member

I'm going to close this PR given #6352 (review). If you feel strongly, feel free to reopen and argue cases where this issue could arise.

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: Reconciler permanently drops Profile Initialization for all remaining entities if a single entity event fails to marshal

3 participants