File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -180,14 +180,23 @@ def _get_error_message_for_tool(self, tool_name: str) -> str:
180180
181181 if not is_valid :
182182 return error_message
183-
183+ tool_name = self . _sanitize_tool_name ( tool_name )
184184 # If all validations pass but we still have an error, return generic message
185+
185186 return (
186187 f"Unable to execute '{ tool_name } ' tool. Please ensure PiecesOS is running "
187188 "and try again. If the problem persists, run:\n \n "
188189 "`pieces restart`"
189190 )
190191
192+ def _sanitize_tool_name (self , tool_name : str ) -> str :
193+ """Sanitize tool name for safe inclusion in messages."""
194+ import re
195+
196+ # Remove control characters and limit length
197+ sanitized = re .sub (r"[^\w\s\-_.]" , "" , tool_name )
198+ return sanitized [:100 ] # Limit to reasonable length
199+
191200 def _get_tools_hash (self , tools ):
192201 """Generate a hash of the tools list for change detection."""
193202 if not tools :
You can’t perform that action at this time.
0 commit comments