Commit 174d852
fix(serenity): add required
<!-- mysticat-pr-skill -->
## 1. Abstract
Adds the required `type: 'ai'` field to the serenity brand-alias re-sync
`updateProject` PATCH body so the request validates against the Semrush
Project Engine gateway.
## 2. Reasoning
The brand-alias re-sync in `src/support/serenity/brand-aliases.js`
called `transport.updateProject(...)` with a body that omitted the
`type` field, which is `required` on `ProjectUpdateRequest`. A live
sweep (captured 2026-06-29) confirmed that a typeless `PATCH
/v1/workspaces/{id}/projects/{pid}` returns `400` (`Key:
'ProjectUpdateRequest.Type' Error:Field validation for 'Type' failed on
the 'required' tag`), while the same PATCH with `type: 'ai'` returns
`200`. As a result, any brand-alias change that actually drifts a
project's `brand_names` would fail in production and silently no-op the
project-level alias sync. The gap went uncaught because no IT exercised
the alias-resync PATCH path against the PE mock, even though the mock
already 400s a typeless PATCH.
## 3. High-level overview of the changes
- Before: the `brand_names` re-sync branch sent `{ brand_name_display?,
brand_names }` — no `type` — so a drifted update 400'd against the live
gateway and the alias sync silently failed.
- After: the PATCH body carries `type: 'ai'` (matching the literal used
at project create-time in `handlers/markets.js` and
`handlers/markets-subworkspace.js`; AIO projects are always type `ai`),
so the request validates and the drifted `brand_names` update succeeds.
- Behaviour is otherwise unchanged: the PATCH still fires only when the
live `brand_names` set has drifted from the desired set; the benchmark
`brand_aliases` PUT path is untouched.
- The three exact-body assertions in the unit test now pin `type: 'ai'`,
so a future regression that drops the field is caught locally.
## 4. Required information
- Jira / issue:
#2720
- Other: adobe/spacecat-shared#1746
## 5. Affected / used mysticat-workspace projects
- spacecat-shared (contract): the PE Counterfact mock enforces the
`type` requirement at the request-validation seam; spacecat-shared PR
#1746 pins the typeless-PATCH 400 as an e2e. This change makes serenity
conform to that contract.
## 7. Test plan
- (a) Local: ran the `brand-aliases` unit suite, which now asserts
`type: 'ai'` on all three `updateProject` body expectations; the
serenity `// @ts-check` type-check gate also covers the touched file. No
live e2e was run this session — the production defect was identified
from the 2026-06-29 live Semrush sweep referenced in the issue.
- (b) dev / stage / prod: after deploy, trigger a brand-alias change
that drifts a serenity-mode brand's `brand_names` (display name or alias
edit) and confirm the `PATCH /v1/workspaces/{id}/projects/{pid}` returns
`200` rather than `400`, and that the project's
`settings.ai.brand_names` reflects the new set.
## 8. Deployment & merge order
- adobe/spacecat-shared#1746 (related): pins the
mock-level typeless-PATCH 400 guard upstream. Independent of this PR —
no hard merge/deploy ordering required; the two together guard the
defect at both the mock layer and the serenity call site.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>type to brand-alias updateProject PATCH (#2721)1 parent 0d09469 commit 174d852
2 files changed
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
132 | 135 | | |
133 | 136 | | |
134 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
| 126 | + | |
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
| |||
231 | 233 | | |
232 | 234 | | |
233 | 235 | | |
| 236 | + | |
234 | 237 | | |
235 | 238 | | |
236 | 239 | | |
| |||
0 commit comments