Repository navigation
Conversation
Dify Cloud returns the top-level "query" field of a knowledge base retrieval response as a bare string, while self-hosted Dify returns an object. DifyResponse modelled it as an object only, so Jackson could not bind the payload and threw, discarding every retrieved record and leaving RAG retrieval empty. Deserialize both shapes with a dedicated deserializer. The field is informational -- the Dify integration never reads it -- so a shape that is neither a string nor an object now yields a null query instead of failing the whole response. Fixes agentscope-ai#1917
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This branch has not been deployed
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.
AgentScope-Java Version
2.1.0-SNAPSHOT
Description
Fixes #1917
DifyResponsemodels the top-levelqueryfield of a knowledge base retrieval response as an object ({"content": "..."}), which is what self-hosted Dify returns. Dify Cloud (api.dify.ai) returns a bare string for the same field:{"query": "ping", "records": [ { "segment": { ... }, "score": 0.9 } ]}Jackson cannot bind a JSON string to
DifyResponse.Query, soDifyRAGClient.retrievethrowsJsonException: Failed to deserialize JSON to ...DifyResponseand every record is discarded:kb_searchreturns nothing against Dify Cloud, while stub responses shaped as an object hide the problem.DifyQueryDeserializer, which maps both"query": "..."and"query": {"content": "..."}toDifyResponse.Query.DifyResponse#getQueryare the tests added here) -- so a shape that is neither a string nor an object yields a null query instead of failing the response. Losing the query text is harmless; losing all records is not.DifyResponse.Query,getQuery()/setQuery()and the self-hosted shape are unchanged, so this is not a breaking change.DifyResponseandDifyDocumentConverterjavadoc.Validation on commit 9797487:
MockWebServerresponse carrying the Dify Cloud payload makestestParseResponseWithBareStringQueryfail on the parent commit withMismatchedInputException: Cannot construct instance of DifyResponse$Query ... from String value ('What is RAG?')-- the sameFailed to deserialize JSON to ...DifyResponseerror reported in [Bug] Dify Cloud 检索接口 query 字段返回字符串,导致 DifyResponse 反序列化失败(kb_search 对 api.dify.ai 引用恒为空) #1917.DifyRAGClientTest: 26 passed, 0 failures, 0 errors. The new tests cover the bare-string shape, the object shape (regression guard) and record parsing for both.Dify*Test,RerankConfigTest,RetrievalModeTest): 64 tests run, 0 failures, 0 errors, 0 skipped; Maven reactor for the module and its dependencies: BUILD SUCCESS, Spotless check included.Checklist
mvn spotless:applymvn test) -- the affected module and its dependencies passed locallydocs/, so none was changed