Skip to content

[FSSDK-11649] Fix FSC failed tests for CMAB #411

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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

Mat001
Copy link
Contributor

@Mat001 Mat001 commented Jun 27, 2025

The issue in the CMAB error handling path within the GetDecision method. When the CMAB API returns an error, the previous implementation attempted to append reasons from the failed API call to the accumulated reasons list. This caused FSC tests to fail because:

  • The reasons weren't properly propagated to downstream consumers
  • When API errors occurred, the Decision object contained incorrect or missing information
  • FSC tests expected specific error reasons to be present in the Decision object
    Fix
    Modified the error handling path to return a clean Decision object with properly initialized reasons

https://jira.sso.episerver.net/browse/FSSDK-11649

@Mat001 Mat001 self-assigned this Jun 27, 2025
@Mat001 Mat001 changed the title [FSSDK-11649] Fix CMAB error handling to properly propagate error reasons in Decisi… [FSSDK-11649] Fix FSC failed tests for CMAB Jun 27, 2025
@Mat001 Mat001 requested a review from raju-opti July 15, 2025 23:42
decisionReasons.AddInfo(message)
return decision, decisionReasons, fmt.Errorf("failed to get CMAB decision: %w", err)
// Add CMAB error to decision reasons
errorMessage := fmt.Sprintf(cmab.CmabFetchFailed, experiment.Key)

Choose a reason for hiding this comment

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

this message processing is also being done in cmab_service. I guess we can do this here and keep the code in cmab_service unchanged?

@@ -51,6 +53,21 @@ func (f CompositeFeatureService) GetDecision(decisionContext FeatureDecisionCont
reasons.Append(decisionReasons)
if err != nil {
f.logger.Debug(err.Error())
// Check if this is a CMAB error - if so, stop the loop and return empty decision
if strings.Contains(err.Error(), "Failed to fetch CMAB data") {

Choose a reason for hiding this comment

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

if there is an error from the featureDecisonfeatureDecisionService.GetDecision() call, we should just return the error from here. The caller of this method should deal with the error.

if strings.Contains(err.Error(), "Failed to fetch CMAB data") {
// Add the CMAB error to reasons before returning - use AddError for critical failures
reasons.AddError(err.Error())
return FeatureDecision{}, reasons, nil // Return empty decision for CMAB errors

Choose a reason for hiding this comment

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

it should return the error here

}
}

// Also check for CMAB errors in decision reasons (when err is nil)

Choose a reason for hiding this comment

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

if there was an error, the featureDecisionService.GetDecision() call must return an error, there should be no implicit errors. Please remove this if block

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.

2 participants