Skip to content

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

Closed

Description

@JayHsu5

Pre-submission checklist | 提交前检查

  • I have searched existing issues and this hasn't been mentioned before | 我已搜索现有问题,确认此问题尚未被提及
  • I have read the project documentation and confirmed this issue doesn't already exist | 我已阅读项目文档并确认此问题尚未存在
  • 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 | 实现意愿

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

Activity

  1. added theissue type on May 22, 2026
  2. added
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on May 29, 2026
  3. added and removed
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on May 29, 2026
  4. added
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    and removed on May 29, 2026
  5. added and removed
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on May 29, 2026
  6. deleted a comment from MaiHHConnect on May 29, 2026
  7. deleted a comment from Memtensor-AI on May 29, 2026
  8. added
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on May 29, 2026
  9. 16 remaining items

  10. self-assigned this
    on Jun 4, 2026
  11. Memtensor-AI commented on Jun 4, 2026

    @Memtensor-AI
    Collaborator

    🤖 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.

  12. added a commit that references this issue on Jun 4, 2026
    c251f02
  13. Memtensor-AI commented on Jun 4, 2026

    @Memtensor-AI
    Collaborator

    ✅ 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: #1883
    Assigned to: @MatthewZhuang, @CarltonXiang, @syzsunshine219
    Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219

  14. added
    ai:testingAI agent is running tests | AI 正在运行测试
    and removed
    ai:codingAI agent is coding | AI 正在编码
    ai:testingAI agent is running tests | AI 正在运行测试
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on Jun 4, 2026
  15. CarltonXiang commented on Jul 7, 2026

    @CarltonXiang
    Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:coreMOS 编排层 / 框架底座 / 跨模块问题

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions