Skip to content

fix(speakers): honour payload bio on createMySpeaker instead of always overriding with member bio#564

Open
romanetar wants to merge 1 commit into
mainfrom
fix/speaker-bio-sync
Open

fix(speakers): honour payload bio on createMySpeaker instead of always overriding with member bio#564
romanetar wants to merge 1 commit into
mainfrom
fix/speaker-bio-sync

Conversation

@romanetar

@romanetar romanetar commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

ref https://app.clickup.com/t/9014802374/86badw3a0

Summary by CodeRabbit

  • Bug Fixes

    • Speaker profile creation now respects submitted profile details over existing member data.
    • If no bio is provided, the speaker profile falls back to the member’s bio as expected.
  • Tests

    • Added regression coverage for speaker creation to verify bio priority and fallback behavior.

…s overriding with member bio

Signed-off-by: romanetar <roman_ag@hotmail.com>
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

createMySpeaker now merges authenticated member defaults behind the validated request payload, then sets member_id from the current member. The test suite adds regression coverage for submitted bio precedence, fallback to member bio, and Doctrine entity-manager reset handling.

Changes

Speaker bio precedence

Layer / File(s) Summary
Payload merge order
app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitSpeakersApiController.php
createMySpeaker builds member defaults from the authenticated member, merges them behind the validated payload, and forces member_id from the current member.
Bio precedence tests
tests/oauth2/OAuth2SummitSpeakersApiTest.php
Adds member creation, authentication, and Doctrine entity-manager reset support, plus regression tests for submitted bio precedence and fallback to the member bio when none is provided.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A bunny hopped through payload lore 🐇
Let user bio bloom at the speaker’s door
If none is sent, the member whispers near
Doctrine burrows stay tidy and clear
Tiny ears twitch: the merge order sings

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: createMySpeaker now respects the submitted bio instead of overwriting it with member bio.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/speaker-bio-sync

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/summit-api/openapi/pr-564/

This page is automatically updated on each push to this PR.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
tests/oauth2/OAuth2SummitSpeakersApiTest.php (1)

2084-2094: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Run cleanup in a finally block so a failed assertion doesn't leak the Member/Speaker.

Assertions on lines 2084-2088 run before the cleanup on lines 2090-2093. If an assertion fails, the test aborts and the created member (and the speaker created by createMySpeaker) are never removed, leaking state into subsequent tests in this class.

Separately, setUserExternalId(mt_rand()) (line 2049) can in rare cases collide with the seeded members' external ids, which could make auth resolution flaky; consider a deterministic unique value derived from $prefix.

♻️ Suggested structure
$this->assertResponseStatus(201);
try {
    $speaker = json_decode($response->getContent());
    $this->assertNotNull($speaker);
    $this->assertEquals($payloadBio, $speaker->bio,
        "Speaker bio must match what the user submitted, not the member/FNid bio.");
} finally {
    $this->resetEmIfNeeded();
    self::$em->remove(self::$em->find(Member::class, $newMember->getId()));
    self::$em->flush();
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/oauth2/OAuth2SummitSpeakersApiTest.php` around lines 2084 - 2094, Move
the cleanup in the test around the response/assertion checks into a finally
block so `createMySpeaker`-created state is always removed even if
`assertResponseStatus`, `assertNotNull`, or `assertEquals` fails. Use the
existing `resetEmIfNeeded()` and `self::$em->remove(...)`/`flush()` cleanup
sequence after the assertions, and also replace the
`setUserExternalId(mt_rand())` value with a deterministic unique value derived
from `$prefix` to avoid rare collisions with seeded members.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/oauth2/OAuth2SummitSpeakersApiTest.php`:
- Around line 2084-2094: Move the cleanup in the test around the
response/assertion checks into a finally block so `createMySpeaker`-created
state is always removed even if `assertResponseStatus`, `assertNotNull`, or
`assertEquals` fails. Use the existing `resetEmIfNeeded()` and
`self::$em->remove(...)`/`flush()` cleanup sequence after the assertions, and
also replace the `setUserExternalId(mt_rand())` value with a deterministic
unique value derived from `$prefix` to avoid rare collisions with seeded
members.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2b7da1f7-fe99-4c0f-b5d1-44a013d78819

📥 Commits

Reviewing files that changed from the base of the PR and between 5d711e3 and 6bedec0.

📒 Files selected for processing (2)
  • app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitSpeakersApiController.php
  • tests/oauth2/OAuth2SummitSpeakersApiTest.php

@romanetar romanetar requested a review from smarcet June 25, 2026 15:31
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