Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(webserver): forbid empty content message update #3390

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions ee/tabby-schema/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,8 @@
input: thread::UpdateMessageInput,
) -> Result<bool> {
let user = check_user(ctx).await?;
input.validate()?;

Check warning on line 1186 in ee/tabby-schema/src/schema/mod.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-schema/src/schema/mod.rs#L1186

Added line #L1186 was not covered by tests

let svc = ctx.locator.thread();
let Some(thread) = svc.get(&input.thread_id).await? else {
return Err(CoreError::NotFound("Thread not found"));
Expand Down
4 changes: 3 additions & 1 deletion ee/tabby-schema/src/schema/thread/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
code::{CodeSearchDocument, CodeSearchHit, CodeSearchScores},
doc::{DocSearchDocument, DocSearchHit},
};
use validator::Validate;

use crate::{juniper::relay::NodeType, Context};

Expand Down Expand Up @@ -44,11 +45,12 @@
}
}

#[derive(GraphQLInputObject, Clone)]
#[derive(GraphQLInputObject, Clone, Validate)]

Check warning on line 48 in ee/tabby-schema/src/schema/thread/types.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-schema/src/schema/thread/types.rs#L48

Added line #L48 was not covered by tests
#[graphql(context = Context)]
pub struct UpdateMessageInput {
pub id: ID,
pub thread_id: ID,
#[validate(length(min = 1, code = "content", message = "content can not be empty"))]
pub content: String,
}

Expand Down
Loading