Skip to content

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

Merged
smarcet merged 2 commits into
mainfrom
fix/speaker-bio-sync
Aug 31, 2026
Merged

fix(speakers): honour payload bio on createMySpeaker instead of always overriding with member bio#564
smarcet merged 2 commits 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 prioritizes submitted profile details over existing member data.
    • Blank or whitespace-only fields fall back to the member’s saved details.
    • When no bio is provided, the speaker profile correctly uses the member’s bio.
  • Tests

    • Added regression coverage for submitted, missing, and blank bio values.

…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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 16acc471-264e-4a85-848f-982701c2a329

📥 Commits

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

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

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

createMySpeaker now preserves submitted member fields, applies member defaults for missing or whitespace-only values, and forces the authenticated member_id. Tests cover submitted, missing, and whitespace-only bio values.

Changes

Speaker bio precedence

Layer / File(s) Summary
Payload merge order
app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitSpeakersApiController.php
createMySpeaker removes whitespace-only default fields, merges member defaults behind the validated payload, and forces member_id from the authenticated member.
Bio precedence tests
tests/oauth2/OAuth2SummitSpeakersApiTest.php
Adds entity-manager reset support and regression tests for submitted, missing, and whitespace-only bio values.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: 🔵 Low · up to bec9c

The endpoint now allows submitted values to override several member-derived speaker fields, not just bio. This is limited to the authenticated user’s own profile, but the broader authority change should receive explicit owner confirmation or follow-up before merging.

Suggested reviewers: smarcet

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. 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 and concisely describes the main change: createMySpeaker now preserves a payload-provided bio instead of overriding it with the 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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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

Form clients commonly serialize untouched fields as empty strings. An
empty or whitespace-only value for the defaultable keys (first_name,
last_name, bio, twitter, irc) won the merge against the member defaults
and created a speaker with an empty field instead of falling back to
the member profile data. On create there is nothing to clear yet, so
such values now count as not sent. The PUT path is untouched: empty
strings there still clear the field.

Adds a boundary regression test: a whitespace-only submitted bio falls
back to the member bio (also covering the trim).
@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.

@smarcet smarcet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@smarcet
smarcet merged commit 429e111 into main Aug 31, 2026
20 checks passed
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.

2 participants