Skip to content

fix: Handle existing branding localization for PhishProtection standard - #282

Open
ZenTopBrandon wants to merge 1 commit into
CyberDrain:devfrom
ZenTopBrandon:fix/phish-protection-branding-conflict
Open

fix: Handle existing branding localization for PhishProtection standard#282
ZenTopBrandon wants to merge 1 commit into
CyberDrain:devfrom
ZenTopBrandon:fix/phish-protection-branding-conflict

Conversation

@ZenTopBrandon

Copy link
Copy Markdown

Summary

Fixes misleading errors from the PhishProtection standard when the tenant's default branding localization already exists but has no custom CSS.

Previously, the standard used the response from /branding/localizations/0/customCSS to infer whether the default localization existed. An existing localization with no custom CSS was therefore treated as missing, causing CIPP to attempt to create localization ID 0 again.

Microsoft Graph correctly rejected that request with:

Another object with the same value for property id already exists.

The standard subsequently applied the CSS successfully, but the recovered creation conflict remained in the Logbook at Error severity and could make the standard appear to have failed.

Changes

  • Query the tenant's branding localizations and explicitly check for localization ID 0.
  • Reuse the existing default localization when it is already present.
  • Create the default localization only when ID 0 is absent.
  • Treat only the specific Graph Request_BadRequest / ObjectConflict response targeting id as a recovered race condition.
  • Log that recovered condition at Info severity.
  • Preserve Error severity and diagnostic data for all other localization creation failures.
  • Continue applying the PhishProtection custom CSS after a recovered conflict.

Why retain conflict handling after the existence check?

The existence check prevents the normal duplicate-create case, but another process could create localization ID 0 between the GET and POST requests.

The targeted ObjectConflict handling covers that race without suppressing unrelated Graph failures.

Tests

Added Pester coverage for:

  • An existing default localization with empty custom CSS.
  • Creating the default localization when ID 0 is absent.
  • Recovering from the specific duplicate-ID race without writing a misleading Error.
  • Retaining Error severity for unexpected localization creation failures.

Check for the default branding localization before creating it, and treat only the known object-conflict race as a recovered informational condition. Keep unexpected creation failures at error severity and cover the behavior with Pester tests.
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

✅ PR title follows Conventional Commits

Received: fix: Handle existing branding localization for PhishProtection standard

Thanks for fixing it!

@github-actions github-actions Bot closed this Aug 14, 2026
@ZenTopBrandon ZenTopBrandon changed the title Handle existing branding localization for PhishProtection standard fix: Handle existing branding localization for PhishProtection standard Aug 14, 2026
@github-actions github-actions Bot reopened this Aug 14, 2026
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.

1 participant