fix(opensearch): pass positional args to transport.perform_request for ddtrace compatibility#3132
Merged
Merged
Conversation
…r ddtrace compatibility (PIP-226) Agent-Logs-Url: https://github.com/deepset-ai/haystack-core-integrations/sessions/7394727c-b32f-412d-9811-4e720db0b0d4 Co-authored-by: ArzelaAscoIi <37148029+ArzelaAscoIi@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix ddtrace error in OpenSearchSQLRetriever
fix(opensearch): pass positional args to transport.perform_request for ddtrace compatibility
Apr 10, 2026
ArzelaAscoIi
approved these changes
Apr 10, 2026
Contributor
Coverage report (opensearch)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
anakin87
requested changes
Apr 13, 2026
| method="POST", | ||
| url="/_plugins/_sql", | ||
| "POST", | ||
| "/_plugins/_sql", |
Member
There was a problem hiding this comment.
let's add a comment explaining why we use positional args here, so we don't forget in the future
| method="POST", | ||
| url="/_plugins/_sql", | ||
| "POST", | ||
| "/_plugins/_sql", |
Member
There was a problem hiding this comment.
let's add a comment explaining why we use positional args here, so we don't forget in the future
…dtrace compatibility Agent-Logs-Url: https://github.com/deepset-ai/haystack-core-integrations/sessions/8aaa7986-fefa-42c4-bd78-8e70e746aa26 Co-authored-by: ArzelaAscoIi <37148029+ArzelaAscoIi@users.noreply.github.com>
Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>
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.
transport.perform_request(...)calls in_query_sqland_query_sql_asyncexplaining why positional args are used (ddtrace compatibility)Original prompt
Issue Title: ddtrace issue when using sqlmetadataretriever
Issue Description: ### Problem
When
OpenSearchSQLRetrieverexecutes a SQL query,ddtrace's Elasticsearch patch intercepts_client.transport.perform_request()and attempts to unpack(method, target) = args. The call arrives with 0 positional arguments, raising aValueErrorthat propagates asDocumentStoreError: Failed to execute SQL query in OpenSearch: not enough values to unpack (expected 2, got 0).Customer / Business Impact
Customers (flagged via Sols) using
OpenSearchSQLRetrieverin environments with Datadog APM (ddtrace) active are completely blocked from executing SQL queries against OpenSearch. All such requests return HTTP 400.Expected Behaviour
SQL queries via
OpenSearchSQLRetrievershould execute successfully regardless of whether Datadog APM (ddtrace) instrumentation is active in the environment.How to Reproduce
ddtrace) instrumentation in the Haystack service.OpenSearchSQLRetrievercomponent (or callOpenSearchDocumentStore._query_sql()directly).SELECT COUNT(*) AS file_count FROM file WHERE file_name IS NOT NULL;ValueError: not enough values to unpack (expected 2, got 0)inside the ddtrace Elasticsearch patch.Code / Configuration
Component configuration used at time of repro:
{ "component_type": "haystack_integrations.components.retrievers.opensearch.sql_retriever.OpenSearchSQLRetriever", "init_params": { "raise_on_failure": true, "fetch_size": 1000, "document_store": { "type": "haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore", "init_parameters": { "index": "Standard-Index-English", "max_chunk_bytes": 104857600, "embedding_dim": 768, "return_embedding": false, "settings": {"index.knn": true}, "create_index": true } } }, "input": { "query": "SELECT COUNT(*) AS file_count FROM file WHERE file_name IS NOT NULL;" } }Full stack trace from API response:
Acceptance Criteria
OpenSearchSQLRetrieversucceed without errors whenddtraceis active.perform_requestsignature.Additional Context
The root cause is in
ddtrace/contrib/internal/elasticsearch/patch.pyline 154:method, target = argsassumes positional args but the OpenSearch client passes them differently. This is addtraceversion compatibility issue with the OpenSearch Python client.🎥 Jam: https://jam.dev/c/887748f3-cfd8-45eb-b173-fd4a30e3d94b
Consolidated by Marvin
Fixes https://linear.app/deepset/issue/PIP-226/ddtrace-issue-when-using-sqlmetadataretriever
Branch Name should include the identifier "PIP-226"
Issue ...