[PR #32225] fix(api): re-raise exceptions in MetadataService to prevent silent failures #33614

Closed
opened 2026-02-21 20:53:36 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/32225

State: closed
Merged: No


Fixes #31964

Summary

  • Five except Exception blocks in MetadataService were catching and logging errors without re-raising, so the API always returned HTTP 200 even when updates failed
  • Added db.session.rollback() and raise to all five blocks: update_documents_metadata, update_metadata_name, delete_metadata, enable_built_in_field, disable_built_in_field
  • Consolidated two separate db.session.commit() calls in update_documents_metadata into one for atomicity

Test plan

  • All 16 existing metadata unit tests pass
  • Verify batch metadata edit now returns error response on failure instead of false success
**Original Pull Request:** https://github.com/langgenius/dify/pull/32225 **State:** closed **Merged:** No --- Fixes #31964 ## Summary - Five `except Exception` blocks in `MetadataService` were catching and logging errors without re-raising, so the API always returned HTTP 200 even when updates failed - Added `db.session.rollback()` and `raise` to all five blocks: `update_documents_metadata`, `update_metadata_name`, `delete_metadata`, `enable_built_in_field`, `disable_built_in_field` - Consolidated two separate `db.session.commit()` calls in `update_documents_metadata` into one for atomicity ## Test plan - [x] All 16 existing metadata unit tests pass - [ ] Verify batch metadata edit now returns error response on failure instead of false success
yindo added the pull-request label 2026-02-21 20:53:36 -05:00
yindo closed this issue 2026-02-21 20:53:36 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#33614