Skip to content

Fix #1679: fix: The timed_with_status method was swallowing exceptions, making debugging di#1883

Open
Memtensor-AI wants to merge 1 commit into
dev-20260604-v2.0.19from
bugfix/autodev-1679
Open

Fix #1679: fix: The timed_with_status method was swallowing exceptions, making debugging di#1883
Memtensor-AI wants to merge 1 commit into
dev-20260604-v2.0.19from
bugfix/autodev-1679

Conversation

@Memtensor-AI
Copy link
Copy Markdown
Collaborator

Description

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.

Related Issue (Required): Fixes #1679

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Executor did not report tests.

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Checklist

  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have created related documentation issue/PR in MemOS-Docs (if applicable)
  • I have linked the issue to this PR (if applicable)
  • I have mentioned the person who will review this PR

@MatthewZhuang, @CarltonXiang, @syzsunshine219 please review this PR.

Reviewer Checklist

The timed_with_status decorator was swallowing exceptions when no
fallback was provided, making debugging difficult. This fix adds an
explicit 'else: raise' clause to re-raise exceptions when fallback
is None or not provided.

Changes:
- src/memos/utils.py: Added else clause to re-raise exceptions
- tests/test_utils_timing.py: Added test cases to verify exception propagation

Fixes #1679
@Memtensor-AI
Copy link
Copy Markdown
Collaborator Author

✅ Automated Test Results: PASSED

All tests passed (35/35 executed, 36 skipped). memos_local_plugin/smoke: 0 passed, 1 skipped, memos_local_plugin/contract: 35 passed, 35 skipped. Duration: 4s

Branch: bugfix/autodev-1679

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

Labels

ai-generated bug Something isn't working | 功能异常

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants