[PR #28462] fix: allow API to access conversations created before upgrade to 1.10.0 #32051

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

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

State: closed
Merged: Yes


Summary

Fixes #28434 - After upgrading from 1.9.1 to 1.10.0, API requests to /v1/messages returned 404 for conversations created before the upgrade.

Root Cause

Commit b76e17b25 (Nov 12, 2025) introduced trigger functionality and refactored EndUser lookup logic with strict EndUser.type matching:

  • New code queries EndUser with type='service-api'
  • Legacy EndUser records may have different type values (e.g., 'browser')
  • Query fails → creates new EndUser with new ID
  • New EndUser.id ≠ old conversation.from_end_user_id → 404 error

Changes

Modified api/services/end_user_service.py:

  • Add fallback query in get_or_create_end_user_by_type() to find legacy end users without type matching
  • Automatically update legacy end user's type field for future consistency
  • Preserve strict type matching for new end users

Backward Compatibility

This fix enables seamless access to conversations created before the upgrade while maintaining type consistency for all future operations.

Test Results

  • Lint checks passed
  • Type checks passed
  • Unit tests: 2454 passed

Test plan

  • Verify API can access conversations created in 1.9.1 after upgrading to 1.10.0
  • Confirm legacy EndUser.type is automatically updated
  • Ensure new conversations work as expected with strict type matching
**Original Pull Request:** https://github.com/langgenius/dify/pull/28462 **State:** closed **Merged:** Yes --- ## Summary Fixes #28434 - After upgrading from 1.9.1 to 1.10.0, API requests to `/v1/messages` returned 404 for conversations created before the upgrade. ## Root Cause Commit `b76e17b25` (Nov 12, 2025) introduced trigger functionality and refactored EndUser lookup logic with strict `EndUser.type` matching: - New code queries EndUser with `type='service-api'` - Legacy EndUser records may have different type values (e.g., 'browser') - Query fails → creates new EndUser with new ID - New EndUser.id ≠ old conversation.from_end_user_id → 404 error ## Changes Modified `api/services/end_user_service.py`: - Add fallback query in `get_or_create_end_user_by_type()` to find legacy end users without type matching - Automatically update legacy end user's type field for future consistency - Preserve strict type matching for new end users ## Backward Compatibility This fix enables seamless access to conversations created before the upgrade while maintaining type consistency for all future operations. ## Test Results - ✅ Lint checks passed - ✅ Type checks passed - ✅ Unit tests: 2454 passed ## Test plan - [ ] Verify API can access conversations created in 1.9.1 after upgrading to 1.10.0 - [ ] Confirm legacy EndUser.type is automatically updated - [ ] Ensure new conversations work as expected with strict type matching
yindo added the pull-request label 2026-02-21 20:50:39 -05:00
yindo closed this issue 2026-02-21 20:50:39 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#32051