Skip to content

fix(bug): Check for the cms background before trying to access it#19448

Merged
vbudhram merged 1 commit intomainfrom
fxa-12391
Sep 15, 2025
Merged

fix(bug): Check for the cms background before trying to access it#19448
vbudhram merged 1 commit intomainfrom
fxa-12391

Conversation

@vbudhram
Copy link
Copy Markdown
Contributor

Because

  • This causes and unexpected error

This pull request

  • Check for the background before trying to access it

Issue that this pull request solves

Closes: https://mozilla-hub.atlassian.net/browse/FXA-12391

Checklist

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).

Other information (Optional)

This will need to be uplifted to stage.

@vbudhram vbudhram requested a review from a team as a code owner September 15, 2025 18:20
@vbudhram vbudhram self-assigned this Sep 15, 2025
@vbudhram vbudhram requested a review from Copilot September 15, 2025 18:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds defensive null checking for CMS background configuration to prevent unexpected errors when accessing background-related properties. The fix ensures that backgrounds property exists before attempting to access nested background configuration values.

  • Added null checks for this.cmsConfig.shared.backgrounds property before accessing defaultLayout
  • Applied the same defensive check in two locations where background configuration is accessed

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@vbudhram vbudhram changed the title fix(bug): Check if CMS config is present before accessing it fix(bug): Check for the cms background before trying to access it Sep 15, 2025
this.cmsConfig &&
this.cmsConfig.shared &&
this.cmsConfig.shared.backgrounds &&
this.cmsConfig.shared.backgrounds.defaultLayout
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.

Why not this.cmsConfig?.shared?.backgrounds?.defaultLayout?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No reason, just followed the existing pattern.

@vbudhram vbudhram merged commit 9b1a847 into main Sep 15, 2025
20 checks passed
@vbudhram vbudhram deleted the fxa-12391 branch September 15, 2025 18:44
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.

3 participants