You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit adds Apache Doris as a new vector database option for Dify's RAG system.
Features:
- Vector similarity search using cosine distance
- Full-text search with BM25 scoring and inverted indexes
- Hybrid search combining vector and text search
- High-performance bulk data loading via StreamLoad
- Connection pooling for efficient resource management
- Support for multi-tenant isolation
Components added:
- DorisVector: Main vector database implementation with cleaned code
- DorisConfig: Configuration model with validation
- DorisConnectionPool: Thread-safe connection management
- DorisVectorFactory: Factory for creating Doris instances
- DORIS_SETUP.md: Complete setup guide in English
- Add type annotations to fix mypy errors (pool config dict, params lists)
- Add USE database statement in _get_cursor to ensure database context
- Add _wait_for_table_normal_state method to wait for schema changes
before creating text index (fixes index creation race condition)
- Extend Redis lock timeout to accommodate schema change waiting
- Update unit tests to account for new USE database statement
DeepSource reviewed changes in the commit range b76c8fa..413534b on this pull request. Below is the summary for the review, and you can see the individual issues we found as review comments.
Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. Please see the DeepSource dashboard for this PR to view those issues.
PR Report Card
Security
× 2 issues
Overall PR Quality
Focus Area: Reliability
Guidance Address 10 critical 'Unexpected any' type issues across various files to improve type safety.
Administrators can configure which issue categories are reported and cause analysis to be marked as failed when detected. This helps prevent bad and insecure code from being introduced in the codebase. If you're an administrator, you can modify this in the repository's settings.
💡 If you're a repository administrator, you can configure the quality gates from the settings.
The reason will be displayed to describe this comment to others. Learn more.
`hashlib.md5` enables collision attacks
The code uses hashlib.md5 to compute a hash of self.table_name, which is cryptographically broken and susceptible to collision attacks. Attackers could generate different inputs that produce the same hash, undermining trust or causing security breaches.
Replace hashlib.md5 with stronger algorithms such as hashlib.sha256 or hashlib.sha512 to ensure cryptographic security and avoid collisions.
The reason will be displayed to describe this comment to others. Learn more.
String-based SQL query construction enables injection attacks
Constructing the SQL DELETE query with f-string interpolation using self.table_name and the placeholders string directly inserts data into the SQL command, exposing the code to SQL injection attacks. An attacker can manipulate self.table_name or ids to execute arbitrary SQL, potentially deleting or corrupting database data.
Use parameterized queries and avoid interpolating untrusted variables directly in SQL command strings. Validate or whitelist self.table_name and pass ids as query parameters to the database adapter to ensure safe escaping and prevent injection.
The reason will be displayed to describe this comment to others. Learn more.
Instance method without `self` wastes memory and CPU
The method test_invalid_analyzer_raises_error is defined with self as parameter but never uses it, resulting in creation of bound methods for class instances and increased memory and CPU consumption. This overhead persists for every instance where the method is accessed.
Decorate the method with @staticmethod to indicate it does not depend on instance state. This avoids creation of bound methods and reduces memory and computation overhead.
The reason will be displayed to describe this comment to others. Learn more.
Assigned variable `pool` is never used
The variable pool holds a DorisConnectionPool object but is never used after its assignment, which wastes memory and may confuse maintainers about its purpose.
Remove the assignment or rename the variable to _ or _unused to indicate intentional non-use, cleaning up the code and improving readability.
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
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.
No description provided.