Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions crates/bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ impl ReducerContext {
/// use spacetimedb::{reducer, ReducerContext, Uuid};
///
/// #[reducer]
/// fn generate_uuid_v4(ctx: &ReducerContext) -> Uuid {
/// fn generate_uuid_v4(ctx: &ReducerContext) {
/// let uuid = ctx.new_uuid_v4();
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The function new_uuid_v4() returns anyhow::Result<Uuid>, but the Result is not being handled here. Since the reducer signature returns (), you need to either:

  1. Handle the error explicitly (e.g., using .unwrap(), .expect(), or a match statement), or
  2. Change the reducer signature to return Result<(), impl std::fmt::Display> and use the ? operator to propagate the error, similar to the generate_uuid_v7 example below.
Suggested change
/// let uuid = ctx.new_uuid_v4();
/// let uuid = ctx.new_uuid_v4().expect("failed to generate UUID v4");

Copilot uses AI. Check for mistakes.
/// log::info!(uuid);
/// }
Expand All @@ -1070,9 +1070,10 @@ impl ReducerContext {
/// use spacetimedb::{reducer, ReducerContext, Uuid};
///
/// #[reducer]
/// fn generate_uuid_v7(ctx: &ReducerContext) -> Result<Uuid, Box<dyn std::error::Error>> {
/// fn generate_uuid_v7(ctx: &ReducerContext) -> Result<(), Box<dyn std::error::Error>> {
/// let uuid = ctx.new_uuid_v7()?;
/// log::info!(uuid);
/// Ok(())
/// }
/// # }
/// ```
Expand Down
Loading