Skip to content

fix(meeting): increase Participant role column length to prevent admission failures#96

Merged
aniebietafia merged 2 commits into
mainfrom
develop
Jun 6, 2026
Merged

fix(meeting): increase Participant role column length to prevent admission failures#96
aniebietafia merged 2 commits into
mainfrom
develop

Conversation

@aniebietafia
Copy link
Copy Markdown
Contributor

@aniebietafia aniebietafia commented Jun 6, 2026

Summary by CodeRabbit

Release Notes

  • Enhancements
    • Increased the maximum length for participant roles, enabling longer role descriptions in meetings.

aniebietafia and others added 2 commits June 6, 2026 22:45
…ssion failures

- Update the Participant model's role column to String(20) to accommodate the 11-character "participant" role.
- Add Alembic migration to update the column length limit in the database.
- Fixes the "Failed to admit" error when hosts admit authenticated users from locked lobbies.

Signed-off-by: aniebietafia <aniebietafia87@gmail.com>
fix(meeting): increase Participant role column length to prevent admi…
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 6, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The pull request expands the Participant.role column constraint from String(10) to String(20) characters. The change is implemented in both the SQLAlchemy model definition and a corresponding Alembic database migration that performs the upgrade and downgrade operations.

Changes

Participant role column expansion

Layer / File(s) Summary
Participant role column length update
app/modules/meeting/models.py, alembic/versions/96532f61566e_increase_participant_role_length.py
The Participant.role column definition is widened from String(10) to String(20) in the SQLAlchemy model, and a new migration file provides upgrade() and downgrade() functions to alter the database column length accordingly, while preserving the default value and nullability constraint.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A rabbit hops through schemas bright,
Where roles grow long, from ten to twenty,
The migration glows with gentle light,
More space for names, now we have plenty!
🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: increasing the Participant role column length to fix admission failures, which directly matches the changeset modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 develop

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
app/modules/meeting/models.py (1)

104-104: Increase Participant.role width to match ParticipantRole values; consider DB-level enforcement.

String(20) on app/modules/meeting/models.py covers all ParticipantRole enum values (host, co_host, participant, guest). Current persistence allows any string because participants.role is a plain Mapped[str] with only uniqueness constraints, while app/modules/meeting/ws_router.py reads role from incoming state (defaulting to "guest"). Consider constraining participants.role to the ParticipantRole set via a SQLAlchemy Enum or a DB CHECK constraint.

🤖 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 `@app/modules/meeting/models.py` at line 104, Participant.role currently uses
mapped_column(String(20)) which allows arbitrary strings; update the model to
enforce the ParticipantRole set at the DB level by replacing String(20) with a
SQLAlchemy Enum tied to the ParticipantRole enum (e.g.,
mapped_column(Enum(ParticipantRole), nullable=False,
default=ParticipantRole.guest)) or, if you must keep a string, increase the
length and add a CheckConstraint limiting values to ParticipantRole members;
adjust any defaults/usages that pass plain strings (ws_router reading/writing
participants.role) to use ParticipantRole enum values or .value consistently.
🤖 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.

Inline comments:
In `@alembic/versions/96532f61566e_increase_participant_role_length.py`:
- Around line 34-44: The downgrade() migration alters participants.role from
length 20 to 10 which will fail or silently truncate existing values >10; before
calling op.alter_column in downgrade(), scan the participants table for any role
strings longer than 10 (e.g., SELECT role WHERE char_length(role) > 10), and
either (a) abort the downgrade with a clear error/log message listing offending
values, or (b) perform a safe migration step to normalize/truncate or map those
roles to permitted 10-char values and write those updates back to the table,
then proceed to call op.alter_column("participants", "role", ...). Ensure this
logic references downgrade(), op.alter_column, and the "participants"."role"
column so the migration explicitly handles or prevents data loss.

---

Nitpick comments:
In `@app/modules/meeting/models.py`:
- Line 104: Participant.role currently uses mapped_column(String(20)) which
allows arbitrary strings; update the model to enforce the ParticipantRole set at
the DB level by replacing String(20) with a SQLAlchemy Enum tied to the
ParticipantRole enum (e.g., mapped_column(Enum(ParticipantRole), nullable=False,
default=ParticipantRole.guest)) or, if you must keep a string, increase the
length and add a CheckConstraint limiting values to ParticipantRole members;
adjust any defaults/usages that pass plain strings (ws_router reading/writing
participants.role) to use ParticipantRole enum values or .value consistently.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef34df81-e17d-4738-8e62-daf1fbbd5d57

📥 Commits

Reviewing files that changed from the base of the PR and between f88760b and 84570a9.

📒 Files selected for processing (2)
  • alembic/versions/96532f61566e_increase_participant_role_length.py
  • app/modules/meeting/models.py

Comment on lines +34 to +44
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"participants",
"role",
existing_type=sa.String(length=20),
type_=sa.VARCHAR(length=10),
existing_nullable=False,
)
# ### end Alembic commands ###
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚖️ Poor tradeoff

Downgrade may fail or truncate data if roles exceed 10 characters.

The downgrade path does not validate or handle existing role values that exceed 10 characters (e.g., "participant" = 11 characters). This could result in:

  • PostgreSQL: Migration failure with data truncation error
  • MySQL/MariaDB: Silent data truncation and corruption

Since the PR title mentions preventing "admission failures" and the context shows "participant" is a valid role value, existing production data likely contains 11-character role values.

🛡️ Recommended fix to ensure safe downgrade

Add data validation before the schema change:

 def downgrade() -> None:
     """Downgrade schema."""
+    # Check for role values that would be truncated
+    connection = op.get_bind()
+    result = connection.execute(
+        sa.text("SELECT COUNT(*) FROM participants WHERE LENGTH(role) > 10")
+    )
+    count = result.scalar()
+    if count > 0:
+        raise ValueError(
+            f"Cannot downgrade: {count} participant(s) have role values exceeding 10 characters. "
+            "Please update or remove these records before downgrading."
+        )
+    
     # ### commands auto generated by Alembic - please adjust! ###
     op.alter_column(

Alternatively, add a comment documenting the risk:

 def downgrade() -> None:
-    """Downgrade schema."""
+    """Downgrade schema.
+    
+    WARNING: This downgrade will fail if any participant records have role values
+    longer than 10 characters (e.g., 'participant'). Ensure all role values are
+    shortened to <= 10 characters before running this downgrade.
+    """
🤖 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 `@alembic/versions/96532f61566e_increase_participant_role_length.py` around
lines 34 - 44, The downgrade() migration alters participants.role from length 20
to 10 which will fail or silently truncate existing values >10; before calling
op.alter_column in downgrade(), scan the participants table for any role strings
longer than 10 (e.g., SELECT role WHERE char_length(role) > 10), and either (a)
abort the downgrade with a clear error/log message listing offending values, or
(b) perform a safe migration step to normalize/truncate or map those roles to
permitted 10-char values and write those updates back to the table, then proceed
to call op.alter_column("participants", "role", ...). Ensure this logic
references downgrade(), op.alter_column, and the "participants"."role" column so
the migration explicitly handles or prevents data loss.

@aniebietafia aniebietafia merged commit acdf88b into main Jun 6, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant