Skip to content

fix: updated delivery type mismatch#2707

Open
anshulk-public wants to merge 2 commits into
mainfrom
fix/delivery-type-mismatch
Open

fix: updated delivery type mismatch#2707
anshulk-public wants to merge 2 commits into
mainfrom
fix/delivery-type-mismatch

Conversation

@anshulk-public

Copy link
Copy Markdown
Contributor

Summary

  • Root cause of noisy alert: Step 5a fired the delivery type mismatch Slack alert before Steps 5c/5e had a chance to auto-correct the type (e.g. autoResolveAuthorUrl detecting AEM CS from RUM bundles, or the EDS hlxConfig path setting AEM_EDGE). This produced false-positive alerts for sites that self-healed within the same request.
  • Fix: Removed Step 5a entirely. Added Step 5f after Step 5e that re-derives the delivery type using rumHost first (EDS pattern → AEM_EDGE, CS publish host pattern → AEM_CS), falling back to findDeliveryType(baseURL) only when rumHost is absent or unrecognised. The check compares against the site's current delivery type post-correction, so the alert only fires when human intervention is actually needed.
  • New export: AEM_CS_PUBLISH_HOST_PATTERN added to validation.js to match publish-pXXX-eXXX.adobeaemcloud.com RUM hosts.
  • Tests updated: Rewrote delivery type mismatch test suite to cover the RUM-host-based detection path, the findDeliveryType fallback, and the skip condition for new sites.

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description. Or if there's no issue created, make sure you
    describe here the problem you're solving.
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes

If the PR is changing the API specification:

  • make sure you add a "Not implemented yet" note the endpoint description, if the implementation is not ready
    yet. Ideally, return a 501 status code with a message explaining the feature is not implemented yet.
  • make sure you add at least one example of the request and response.

If the PR is changing the API implementation or an entity exposed through the API:

  • make sure you update the API specification and the examples to reflect the changes.

If the PR is introducing a new audit type:

  • make sure you update the API specification with the type, schema of the audit result and an example

Related Issues

Thanks for contributing!

@github-actions

Copy link
Copy Markdown

This PR will trigger a patch release when merged.

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../controllers/plg/plg-onboarding/onboarding-flow.js 95.91% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@MysticatBot MysticatBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey @anshulk-public,

⚠ Degraded review - no spec document was found for this change (searched the PR links, the touched repos' docs, the architecture/guidelines docs, and linked Jira). This review covers code-level quality but could not validate the change against an agreed design, so confidence is reduced. Add a spec link (PR template section 4) and re-request review for a full-confidence pass.

Verdict: Request changes - two new code paths lack test coverage.
Complexity: LOW - small diff, single-service bug fix.
Changes: Moves delivery type mismatch detection from Step 5a (before auto-correction) to Step 5f (after), and adds rumHost-based pattern matching before falling back to findDeliveryType (3 files).
Note: CI checks are currently pending - confirm they pass before merge.

Must fix before merge

  1. [Important] Missing test for AEM_CS publish host pattern detection - src/controllers/plg/plg-onboarding/onboarding-flow.js:701 (details inline)
  2. [Important] Missing test for unrecognised rumHost falling through to findDeliveryType - src/controllers/plg/plg-onboarding/onboarding-flow.js:705 (details inline)
Non-blocking (3): minor issues and suggestions
  • nit: Removed expect(findDeliveryTypeStub).to.have.been.calledOnceWith(TEST_BASE_URL) assertion in the fallback test weakens the contract check - consider restoring a calledWith(TEST_BASE_URL) assertion - test/controllers/plg/plg-onboarding/site-setup.test.js:414
  • suggestion: Use EDS_HOST_PATTERN.test(rumHost) instead of rumHost.match(EDS_HOST_PATTERN) when only a boolean is needed (avoids allocating a match array) - src/controllers/plg/plg-onboarding/onboarding-flow.js:699
  • suggestion: Consider adding unit tests for AEM_CS_PUBLISH_HOST_PATTERN regex edge cases (.net variant, uppercase, non-matching hosts with similar prefixes) in validation's test file - src/controllers/plg/plg-onboarding/validation.js:19

Skill: pr-review | Model: us.anthropic.claude-opus-4-6-v1[1m] | Duration: 2m 4s | Cost: $3.70 | Commit: 6f06b7af9bacad19dfd88b543587f363f1460a72
If this code review was useful, please react with 👍. Otherwise, react with 👎.

// Skip for newly created sites and preset-delivery-type flows — no prior type to compare.
// Detection order: rumHost (EDS pattern → AEM_EDGE, CS publish pattern → AEM_CS),
// falling back to findDeliveryType(baseURL) only when rumHost is absent or unrecognised.
if (!presetDeliveryType && !steps.siteCreated) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (blocking): The AEM_CS_PUBLISH_HOST_PATTERN branch is a newly introduced code path with a new regex, but has zero test coverage. The EDS pattern path has a dedicated test (alerts via Slack using rumHost EDS pattern without calling findDeliveryType) - add an equivalent for the CS publish pattern.

Suggested test: set autoResolveAuthorUrlStub to resolve { host: 'publish-p12345-e67890.adobeaemcloud.com' } with stored delivery type aem_edge, assert the alert fires with detected type aem_cs, and findDeliveryTypeStub is NOT called.

let detectedDeliveryType;
if (rumHost) {
if (rumHost.match(EDS_HOST_PATTERN)) {
detectedDeliveryType = SiteModel.DELIVERY_TYPES.AEM_EDGE;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (blocking): When rumHost is present but matches neither EDS_HOST_PATTERN nor AEM_CS_PUBLISH_HOST_PATTERN, detectedDeliveryType remains undefined and the code falls through to findDeliveryType. This is a distinct scenario from "rumHost absent" (where RUM fails entirely) - the existing tests only cover the absent case.

Suggested test: set autoResolveAuthorUrlStub to resolve { host: 'custom.example.com' } (unrecognised host), assert findDeliveryType IS called as fallback.

@MysticatBot MysticatBot added ai-reviewed Reviewed by AI complexity:low AI-assessed PR complexity: LOW labels Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-reviewed Reviewed by AI complexity:low AI-assessed PR complexity: LOW

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants