Skip to content

fix(serenity): add required type to brand-alias updateProject PATCH#2721

Merged
rainer-friederich merged 2 commits into
mainfrom
fix/2720
Jun 29, 2026
Merged

fix(serenity): add required type to brand-alias updateProject PATCH#2721
rainer-friederich merged 2 commits into
mainfrom
fix/2720

Conversation

@rainer-friederich

Copy link
Copy Markdown
Contributor

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

5. Affected / used mysticat-workspace projects

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

🤖 Generated with Claude Code

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: #2720

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 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 @rainer-friederich,

Verdict: Approve - clean, well-scoped bug fix with adequate test coverage.
Complexity: TRIVIAL - 6 lines, 2 files, single call-site fix.
Changes: Adds the required type: 'ai' field to the brand-alias re-sync updateProject PATCH body so it validates against the Semrush Project Engine gateway (2 files).


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

@MysticatBot MysticatBot added ai-reviewed Reviewed by AI complexity:trivial AI-assessed PR complexity: TRIVIAL labels Jun 29, 2026
@rainer-friederich
rainer-friederich enabled auto-merge (squash) June 29, 2026 12:30
@github-actions

Copy link
Copy Markdown

This PR will trigger a patch release when merged.

@rainer-friederich
rainer-friederich merged commit 174d852 into main Jun 29, 2026
20 checks passed
@rainer-friederich
rainer-friederich deleted the fix/2720 branch June 29, 2026 12:41
solaris007 pushed a commit that referenced this pull request Jun 29, 2026
## [1.609.3](v1.609.2...v1.609.3) (2026-06-29)

### Bug Fixes

* **serenity:** add required `type` to brand-alias updateProject PATCH ([#2721](#2721)) ([174d852](174d852)), closes [Hi#level](https://github.com/Hi/issues/level) [#1746](#1746)
@solaris007

Copy link
Copy Markdown
Member

🎉 This PR is included in version 1.609.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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:trivial AI-assessed PR complexity: TRIVIAL released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants