MemOS icon indicating copy to clipboard operation
MemOS copied to clipboard

fix: The timed_with_status method was swallowing exceptions, making debugging difficult

Open JayHsu5 opened this issue 6 months ago • 3 comments

Pre-submission checklist | 提交前检查

  • [x] I have searched existing issues and this hasn't been mentioned before | 我已搜索现有问题,确认此问题尚未被提及
  • [x] I have read the project documentation and confirmed this issue doesn't already exist | 我已阅读项目文档并确认此问题尚未存在
  • [x] This issue is specific to MemOS and not a general software issue | 该问题是针对 MemOS 的,而不是一般软件问题

Bug Description | 问题描述

https://github.com/MemTensor/MemOS/blob/main/src/memos/utils.py The timed_with_status method was swallowing exceptions, making debugging difficult

How to Reproduce | 如何重现

Incorrect request URL or API key in the .env file

Environment | 环境信息

docker compose

Additional Context | 其他信息

No response

Willingness to Implement | 实现意愿

  • [x] I'm willing to implement this myself | 我愿意自己解决
  • [ ] I would like someone else to implement this | 我希望其他人来解决

JayHsu5 avatar May 11 '26 03:05 JayHsu5

🤖 AutoDev has picked up this issue and started working on it.

Task ID: 8513e5d0d07f0f2d Working branch: bugfix/autodev-1679 Target branch: dev-20260604-v2.0.19 Workflow: opsp (analysis → coding → testing → PR)

I will post the PR link here once done. If I need more information, I will ask in the comments.

Memtensor-AI avatar Jun 04 '26 11:06 Memtensor-AI

✅ AutoDev task 8513e5d0d07f0f2d completed.

Summary: Fixed the bug in timed_with_status decorator where exceptions were being swallowed when no fallback was provided.

Root Cause: The decorator's except block caught exceptions but only returned a fallback result when a fallback function was provided. When no fallback existed, the exception was silently suppressed, causing the decorated function to return None instead of propagating the error.

Fix: Added an explicit else: raise clause after the fallback check to re-raise the exception when no fallback is provided. This preserves the decorator's timing and logging functionality while ensuring exceptions propagate correctly for debugging.

Changes:

  • src/memos/utils.py: Added else clause to re-raise exceptions (lines 182-184)
  • tests/test_utils_timing.py: Added two test cases to verify exceptions propagate correctly without fallback and with explicit fallback=None

Testing: Created and ran a standalone verification script that confirmed:

  1. Exceptions now propagate correctly when no fallback is provided
  2. Fallback mechanism still works when a fallback function is provided
  3. Normal execution (success case) continues to work as expected

This fix resolves the debugging difficulty reported in issue #1679 where incorrect API keys or URLs would fail silently instead of raising clear exceptions.

Base branch: dev-20260604-v2.0.19 Branch: bugfix/autodev-1679 Commit: c251f02 PR: https://github.com/MemTensor/MemOS/pull/1883 Assigned to: @MatthewZhuang, @CarltonXiang, @syzsunshine219 Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219

Memtensor-AI avatar Jun 04 '26 11:06 Memtensor-AI

Fixed by merged PR #1885 and released to main via #2058.

CarltonXiang avatar Jul 07 '26 13:07 CarltonXiang