Fix #1679: fix: The timed_with_status method was swallowing exceptions, making debugging di#1883
Open
Memtensor-AI wants to merge 1 commit into
Open
Fix #1679: fix: The timed_with_status method was swallowing exceptions, making debugging di#1883Memtensor-AI wants to merge 1 commit into
Memtensor-AI wants to merge 1 commit into
Conversation
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
5 tasks
Collaborator
Author
✅ Automated Test Results: PASSEDAll 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: raiseclause 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:
Testing: Created and ran a standalone verification script that confirmed:
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.
How Has This Been Tested?
Executor did not report tests.
Checklist
@MatthewZhuang, @CarltonXiang, @syzsunshine219 please review this PR.
Reviewer Checklist