From 3173a31bba38c062f019f5f0b006545f75c38398 Mon Sep 17 00:00:00 2001 From: Rainer Friederich Date: Mon, 29 Jun 2026 14:16:57 +0200 Subject: [PATCH] fix(serenity): add required `type` to brand-alias updateProject PATCH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The brand-alias re-sync called transport.updateProject(...) with a body that omitted the required `type` field on ProjectUpdateRequest, so any drifted brand_names update 400s against the live Semrush Project Engine gateway (Go-validator: 'Type' failed on the 'required' tag) — silently no-oping the project-level alias sync. Add `type: 'ai'` to the PATCH body, matching the literal used at project create-time (handlers/markets.js, handlers/markets-subworkspace.js). AIO projects are always type 'ai'. Pin it in the three updateProject body assertions in the unit test. Fixes: https://github.com/adobe/spacecat-api-service/issues/2720 Co-Authored-By: Claude Opus 4.8 (1M context) --- src/support/serenity/brand-aliases.js | 3 +++ test/support/serenity/brand-aliases.test.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/support/serenity/brand-aliases.js b/src/support/serenity/brand-aliases.js index b729301b84..43573776d2 100644 --- a/src/support/serenity/brand-aliases.js +++ b/src/support/serenity/brand-aliases.js @@ -129,6 +129,9 @@ export async function syncBrandAliasesAcrossMarkets( if (!sameAliasSet(currentBrandNames, desiredBrandNames)) { // eslint-disable-next-line no-await-in-loop await transport.updateProject(workspaceId, projectId, { + // `type` is required on ProjectUpdateRequest — the Semrush gateway + // (and the PE mock) 400 a typeless PATCH. AIO projects are always 'ai'. + type: 'ai', ...(hasText(display) ? { brand_name_display: display } : {}), brand_names: desiredBrandNames, }); diff --git a/test/support/serenity/brand-aliases.test.js b/test/support/serenity/brand-aliases.test.js index f0136ea641..ac9559d6b6 100644 --- a/test/support/serenity/brand-aliases.test.js +++ b/test/support/serenity/brand-aliases.test.js @@ -87,6 +87,7 @@ describe('brand-aliases helpers', () => { const result = await syncBrandAliasesAcrossMarkets(transport, aliases, 'Brand', WS, undefined); expect(transport.updateProject).to.have.been.calledOnceWith(WS, 'p-us', { + type: 'ai', brand_name_display: 'Brand', brand_names: ['Brand', 'Acme', 'Acme Inc'], }); @@ -122,6 +123,7 @@ describe('brand-aliases helpers', () => { ); expect(transport.updateProject).to.have.been.calledOnceWith(WS, 'p-us', { + type: 'ai', brand_name_display: 'Brand', brand_names: ['Brand', 'Acme'], }); @@ -231,6 +233,7 @@ describe('brand-aliases helpers', () => { ); expect(transport.updateProject).to.have.been.calledOnceWith(WS, 'p-us', { + type: 'ai', brand_names: ['Acme'], // no brand_name_display key }); expect(transport.updateBenchmark).to.not.have.been.called;