fix[sfcc]: ENG-11447 surface specific auth errors and trim Einstein settings#4306
fix[sfcc]: ENG-11447 surface specific auth errors and trim Einstein settings#4306AishwaryaParab merged 2 commits intomainfrom
Conversation
|
|
View your CI Pipeline Execution ↗ for commit a395b32
☁️ Nx Cloud last updated this comment at |
| } | ||
| async validateConfig() { | ||
| const response = await this.request(`validate-config`); | ||
| if (response.errors) { |
There was a problem hiding this comment.
Are the new changes type safe?
There was a problem hiding this comment.
Updated the impl. and added checks for response.errors and other new changes.
sanyamkamat
left a comment
There was a problem hiding this comment.
plugins/salesforce-commerce-api-plugin/src/plugin.ts changes looks good to me. Just verify edge cases around the response.errors block updates.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| if (detail) { | ||
| console.error('[SFCommerce] Authentication failed. Salesforce error:', detail); | ||
| } | ||
| throw 'We failed to authenticate your access to Salesforce Commerce Cloud B2C API. Please review all plugin fields and make sure they are correct.'; |
There was a problem hiding this comment.
Specific Salesforce error detail not appended to thrown message
Medium Severity
The detail extracted from errors[0]?.title is only logged via console.error but is never appended to the thrown error string on line 101. The thrown message is the same generic string as before, so the user never sees the specific Salesforce reason. The PR description explicitly states the intent is to "append the specific Salesforce reason to the error message shown to the user," but the implementation only surfaces it in the developer console.
There was a problem hiding this comment.
This is intended. The error message in the popup will remain the same. More info will be provided in the console.


Description
When Salesforce rejects authentication (e.g. "redirect_uri doesn't match the registered redirects"), the specific error message from Salesforce was available in the server response but was being discarded in
validateConfig(), which always threw the same generic string regardless of the actual failure reason.Changes:
validateConfig()now readsresponse.errors[0].titleand appends the specific Salesforce reason to the error message shown to the user..trim()when readingeinsteinIdandeinsteinSiteIdfrom settings, consistent with the existing pattern in the headless plugin.JIRA Ticket:
https://builder-io.atlassian.net/browse/ENG-11447
Testing:
https://www.notion.so/builderio/Testing-SFCC-Plugin-3173d7274be5802bb5fdd27ddd35ad86
Note
Low Risk
Low risk: limited to config validation and settings parsing, with no changes to core commerce read/search flows. Main risk is rejecting configs that previously passed due to stricter response handling.
Overview
Improves Salesforce Commerce plugin config validation by treating both
errors[]and unexpected{ message }responses as authentication failures, and logging the Salesforce-provided failure detail to aid debugging.Also trims whitespace from
einsteinIdandeinsteinSiteIdbefore deciding whether to enable Einstein recommenders, reducing failures caused by accidental spaces.Written by Cursor Bugbot for commit a395b32. This will update automatically on new commits. Configure here.