Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 1, 2025

After upgrading to 4.5.0, users see 'DocumentStorage' object has no attribute 'connection' errors in logs when using knowledge base features. This occurs because the 4.5.0 refactor migrated DocumentStorage from synchronous (self.connection) to asynchronous operations (self.engine), but cached bytecode or outdated plugins still reference the old attribute.

Changes

  • Add defensive @property connection to DocumentStorage that raises AttributeError with migration guidance:

    • Shell commands to clear Python cache files
    • Instructions to replace self.connection with self.engine and use async with self.get_session()
    • Reference to source code examples
  • Update v4.5.1 changelog with fix reference

Example

Old code attempting to access the removed attribute now gets actionable feedback:

storage = DocumentStorage(db_path)
_ = storage.connection  # Raises:
# AttributeError: DocumentStorage.connection attribute was removed in AstrBot 4.5.0.
# The database now uses async operations with self.engine and async context managers.
# 
# If you're seeing this error, please:
# 1. Clear Python cache files: find data/plugins -name '*.pyc' -delete && ...
# 2. Update any custom plugins that use DocumentStorage:
#    - Replace 'self.connection' with 'self.engine'
#    - Use 'async with self.get_session() as session' for database operations
# 3. Restart AstrBot

The fix is defensive only—no functional changes to DocumentStorage operations.

Original prompt

#3191
修复这个issue


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

- Add defensive @Property to DocumentStorage that raises helpful error when old code tries to access .connection
- Update v4.5.1 changelog with fix for issue #3191
- The .connection attribute was removed in 4.5.0 refactor; this provides clear error message for users with cached bytecode or outdated plugins

Co-authored-by: LIghtJUNction <[email protected]>
@LIghtJUNction LIghtJUNction requested a review from Copilot November 1, 2025 18:15
- Add specific instructions for plugin developers (use self.engine and get_session())
- Improve shell command with proper command chaining and error handling
- Make error message more actionable with concrete examples

Co-authored-by: LIghtJUNction <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@LIghtJUNction LIghtJUNction requested a review from Copilot November 1, 2025 18:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Copilot AI changed the title [WIP] Fix issue with AstrBot functionality Fix AttributeError for removed DocumentStorage.connection in 4.5.0 Nov 1, 2025
Copilot AI requested a review from LIghtJUNction November 1, 2025 18:20
Copilot finished work on behalf of LIghtJUNction November 1, 2025 18:20
@LIghtJUNction LIghtJUNction requested a review from Copilot November 1, 2025 18:25
@LIghtJUNction LIghtJUNction marked this pull request as ready for review November 1, 2025 18:26
@auto-assign auto-assign bot requested review from Larch-C and anka-afk November 1, 2025 18:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

@LIghtJUNction LIghtJUNction requested a review from Copilot November 1, 2025 18:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@LIghtJUNction LIghtJUNction marked this pull request as draft November 1, 2025 19:02
@LIghtJUNction LIghtJUNction deleted the copilot/fix-issue-3191 branch November 7, 2025 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants