Skip to content

Conversation

@dangusev
Copy link
Contributor

@dangusev dangusev commented Dec 22, 2025

  • ID is not always random (previously was randomly generated only once on import)
  • "image" param is passed to the API

Also fixes #200

Summary by CodeRabbit

  • New Features

    • User creation now supports an optional image parameter for profile customization.
    • The create_user function now returns the created user object for immediate use.
  • Changes

    • Refined ID generation logic for new user accounts.

✏️ Tip: You can customize this high-level summary in your review settings.

- ID is not always random (previously was randomly generated only once on import)
- "image" param is passed to the API
@coderabbitai
Copy link

coderabbitai bot commented Dec 22, 2025

Walkthrough

Modified the create_user method in the Stream client to correctly pass the image parameter to UserRequest, fix UUID generation to occur at runtime rather than definition time, and return the constructed user object with proper type annotation.

Changes

Cohort / File(s) Change Summary
User creation method updates
getstream/stream.py
Added FullUserResponse to imports; updated create_user (async and sync) to accept image parameter, changed id default from str(uuid4()) to empty string with runtime generation via id = id or str(uuid4()), pass image to UserRequest constructor, and return the user object with FullUserResponse type annotation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify that runtime UUID generation (id or str(uuid4())) correctly handles all input cases
  • Confirm FullUserResponse type annotation aligns with actual return value structure
  • Validate that the image parameter is now properly threaded through to UserRequest

Poem

🐰 A rabbit hops with joy so bright,
The image field now fixed just right!
UUIDs born at runtime's call,
No more silent fails for avatars tall!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and concisely describes the main change: fixing the create_user method in both Stream and AsyncStream classes.
Linked Issues check ✅ Passed The PR successfully addresses all coding objectives from issue #200: passing the image parameter to UserRequest and fixing ID generation to occur per-call rather than once at import.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the create_user method and its related imports; no unrelated or out-of-scope modifications are present.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/create-user

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

@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: 0

🧹 Nitpick comments (2)
getstream/stream.py (2)

215-228: Consider using None instead of empty string for optional image parameter.

The fix for ID generation is correct—moving UUID generation from default argument to runtime avoids the classic Python pitfall where default mutable/computed values are evaluated only once at definition time.

However, the image parameter defaults to "" and is always passed to UserRequest. According to UserRequest's definition, image is Optional[str] with default None. Passing an empty string when no image is intended could differ semantically from passing None (or omitting it), potentially causing unexpected API behavior.

🔎 Suggested fix
     async def create_user(
-        self, name: str = "", id: str = "", image: str = ""
+        self, name: str = "", id: str = "", image: Optional[str] = None
     ) -> FullUserResponse:
         """
         Creates or updates users. This method performs an "upsert" operation,
         where it checks if each user already exists and updates their information
         if they do, or creates a new user entry if they do not.
         """
         id = id or str(uuid4())
-        user = UserRequest(name=name, id=id, image=image)
+        user = UserRequest(name=name, id=id, image=image if image else None)

334-347: Same recommendation applies: use Optional[str] = None for image.

The core fixes are correct:

  • ID generation at runtime instead of definition time ✓
  • image parameter is now passed to UserRequest
  • Return type annotation added ✓

Apply the same refactor suggested for AsyncStream.create_user to keep both methods consistent.

🔎 Suggested fix
     def create_user(
-        self, name: str = "", id: str = "", image: str = ""
+        self, name: str = "", id: str = "", image: Optional[str] = None
     ) -> FullUserResponse:
         """
         Creates or updates users. This method performs an "upsert" operation,
         where it checks if each user already exists and updates their information
         if they do, or creates a new user entry if they do not.
         """
         id = id or str(uuid4())
-        user = UserRequest(name=name, id=id, image=image)
+        user = UserRequest(name=name, id=id, image=image if image else None)
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 30dc844 and 7a2ba0c.

📒 Files selected for processing (1)
  • getstream/stream.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Plugins that work with audio, video, or WebRTC functionality should depend on getstream[webrtc] instead of just getstream to access WebRTC-related dependencies like aiortc, numpy, torch, torchaudio, soundfile, scipy, deepgram-sdk, and elevenlabs

Files:

  • getstream/stream.py
🧬 Code graph analysis (1)
getstream/stream.py (1)
getstream/models/__init__.py (2)
  • FullUserResponse (8957-9057)
  • UserRequest (19883-19907)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Tests (3.11)
  • GitHub Check: Tests (3.12)
  • GitHub Check: Tests (3.10)
  • GitHub Check: Tests (3.13)
🔇 Additional comments (1)
getstream/stream.py (1)

17-17: LGTM!

Import of FullUserResponse is appropriate for the new return type annotations.

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.

The create_user function in Stream doesn’t pass the image field correctly, which causes the user avatar to fail to display.

2 participants