Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix: file size name limit (#2109)
Will Hutchinson54d1186bf5db
diff --git a/rust/cloud-storage/chat/src/domain/models.rs b/rust/cloud-storage/chat/src/domain/models.rsindex 5ea6dc4a5c..bf863dd6dc 100644--- a/rust/cloud-storage/chat/src/domain/models.rs+++ b/rust/cloud-storage/chat/src/domain/models.rs@@ -16,6 +16,9 @@ pub enum ChatErr {/// An unexpected error occurred.#[error(transparent)]Unknown(#[from] anyhow::Error),+ /// Bad request+ #[error("bad request: {0}")]+ BadRequest(String),}/// Arguments for creating a new chat.diff --git a/rust/cloud-storage/chat/src/domain/service.rs b/rust/cloud-storage/chat/src/domain/service.rsindex b5671a2264..8bf2234c4a 100644--- a/rust/cloud-storage/chat/src/domain/service.rs+++ b/rust/cloud-storage/chat/src/domain/service.rs@@ -39,6 +39,10 @@ impl<R: ChatRepo> ChatService for ChatServiceImpl<R> {user_id: MacroUserIdStr<'static>,args: CreateChatArgs,) -> Result<String, ChatErr> {+ if args.name.chars().count() > 100 {+ return Err(ChatErr::BadRequest("name too long".to_string()));+ }+self.repo.create(user_id, args).await}@@ -106,6 +110,12 @@ impl<R: ChatRepo> ChatService for ChatServiceImpl<R> {entity_access_receipt: EntityAccessReceipt<OwnerAccessLevel>,args: PatchChatArgs,) -> Result<(), ChatErr> {+ if let Some(name) = args.name.as_ref()+ && name.chars().count() > 100+ {+ return Err(ChatErr::BadRequest("name too long".to_string()));+ }+let user_id = extract_user_id(&entity_access_receipt)?;let chat_id = &entity_access_receipt.entity().entity_id;self.repo.patch(user_id, chat_id, args).awaitdiff --git a/rust/cloud-storage/chat/src/inbound/mod.rs b/rust/cloud-storage/chat/src/inbound/mod.rsindex 69872539cd..1454506d92 100644--- a/rust/cloud-storage/chat/src/inbound/mod.rs+++ b/rust/cloud-storage/chat/src/inbound/mod.rs@@ -105,11 +105,14 @@ pub enum ChatHandlerErr {Internal,/// The requested resource was not found.NotFound,+ /// The request was bad+ BadRequest(String),}impl From<ChatErr> for ChatHandlerErr {fn from(err: ChatErr) -> Self {match err {+ ChatErr::BadRequest(e) => ChatHandlerErr::BadRequest(e),ChatErr::NotFound => ChatHandlerErr::NotFound,ChatErr::Unknown(e) => {tracing::error!(error=?e, "chat handler error");@@ -122,11 +125,14 @@ impl From<ChatErr> for ChatHandlerErr {impl IntoResponse for ChatHandlerErr {fn into_response(self) -> axum::response::Response {let (status, msg) = match self {- ChatHandlerErr::Internal => {- (StatusCode::INTERNAL_SERVER_ERROR, "Internal server error")- }- ChatHandlerErr::NotFound => (StatusCode::NOT_FOUND, "Not found"),+ ChatHandlerErr::Internal => (+ StatusCode::INTERNAL_SERVER_ERROR,+ "Internal server error".to_string(),+ ),+ ChatHandlerErr::NotFound => (StatusCode::NOT_FOUND, "Not found".to_string()),+ ChatHandlerErr::BadRequest(e) => (StatusCode::BAD_REQUEST, e),};+(status, msg).into_response()}}diff --git a/rust/cloud-storage/document_storage_service/src/api/projects/create_project.rs b/rust/cloud-storage/document_storage_service/src/api/projects/create_project.rsindex 10b639d111..d35aca4293 100644--- a/rust/cloud-storage/document_storage_service/src/api/projects/create_project.rs+++ b/rust/cloud-storage/document_storage_service/src/api/projects/create_project.rs@@ -59,6 +59,10 @@ async fn create_project_v2(user_context: MacroUserExtractor,req: CreateProjectRequest,) -> Result<Project, (StatusCode, String)> {+ if req.name.chars().count() > 100 {+ return Err((StatusCode::BAD_REQUEST, "name too long".to_string()));+ }+let share_permission = SharePermissionV2::new_project_share_permission();let project = match macro_db_client::projects::create_project_v2(diff --git a/rust/cloud-storage/document_storage_service/src/api/projects/edit_project.rs b/rust/cloud-storage/document_storage_service/src/api/projects/edit_project.rsindex a5d388f9e2..8e8a852bbf 100644--- a/rust/cloud-storage/document_storage_service/src/api/projects/edit_project.rs+++ b/rust/cloud-storage/document_storage_service/src/api/projects/edit_project.rs@@ -98,6 +98,12 @@ async fn edit_project_v2(id: String,req: PatchProjectRequestV2,) -> Result<(), (StatusCode, String)> {+ if let Some(name) = req.name.as_ref()+ && name.chars().count() > 100+ {+ return Err((StatusCode::BAD_REQUEST, "name too long".to_string()));+ }+// Need to ensure we are not nesting the projectif let Some(project_parent_id) = req.project_parent_id.as_ref() {if users_access_level != AccessLevel::Owner {diff --git a/rust/cloud-storage/documents/src/domain/service.rs b/rust/cloud-storage/documents/src/domain/service.rsindex 85991e9705..28212ea260 100644--- a/rust/cloud-storage/documents/src/domain/service.rs+++ b/rust/cloud-storage/documents/src/domain/service.rs@@ -476,6 +476,10 @@ impl<R: DocumentRepo, U: PresignedUploadUrlPort, T: TaskPropertiesPort, C: Conneargs: CreateDocumentRepoArgs,job_id: Option<String>,) -> Result<CreateDocumentResponseData, DocumentError> {+ if args.document_name.chars().count() > 100 {+ return Err(DocumentError::BadRequest("name too long".to_string()));+ }+let file_type = args.file_type;let project_id = args.project_id;let sha = args.sha.clone();@@ -577,6 +581,12 @@ impl<R: DocumentRepo, U: PresignedUploadUrlPort, T: TaskPropertiesPort, C: Connedocument_context: DocumentBasic,args: EditDocumentServiceArgs,) -> Result<(), DocumentError> {+ if let Some(name) = args.document_name.as_ref()+ && name.chars().count() > 100+ {+ return Err(DocumentError::BadRequest("name too long".to_string()));+ }+// Check owner-only restrictions for authenticated usersif let entity_access::domain::models::EntityPermission::AccessLevel { access_level } =entity_access_receipt.entity_permission()