Closed NarekA closed 8 months ago
Note that removing theMyDocument.other_doc
field makes the example work again.
Hey @NarekA,
Thanks for reporting the issue. If you have a fix proposal we would be glad to get the contribution
Of these solutions, do any of them make more sense to you?
Use http get with a body. See this link
Sending a body with a GET request has an undefined behavior in the specifications, nevertheless, it is supported by FastAPI, only for very complex/extreme use cases.
I like this one, but it looks like fastAPI might not include the fields in the docs.
- Use a different http method
The best solution if it's possible
- Serialize/deserialize the fields before IO.
Might make more sense to serialize the whole object as one param rather than try serializing individual params
Any reason we can't use http post
?
@JoanFM Any reason this is using get?
@alaeddine-13 may have better insights as per this
@NarekA Actually the convention when implementing SSE in HTTP is to use GET methods instead of POST. The drawback of using GET is having to serialize the document as query string parameters. However, developers can use clients that follow the convention when using SSE. For instance, mozilla's js client EventSource implements SSE client using GET method. I suggest flattening your document schema in case @JoanFM I remember wanting to include a duplicate POST method for such a case, such that, if you want to follow convention -> use GET endpoint and if you want nested schemas -> use POST endpoint
@alaeddine-13 we are currently working around this by "flattening" the document, but that effectively removes any benefits of the upgrade to Docarray V2. It also means that the framework doesn't support all docarray inputs (for http at least) and that should be communicated. Would it be hard to create a second endpoint? I could look into this one if it helps.
We are definitely going to look into solving this issue. Yoy are right, in the Documentation is not stated
@JoanFM @alaeddine-13 I drafted a PR that seems to fix this issue for me: https://github.com/jina-ai/jina/pull/6091/files
It seems nice @NarekA,
I added some comments to the PR
Describe the bug
Http streaming breaks when documents have fields which are not
str
,int
, orfloat
. This includes dicts, bools, and nested objects. The example below works for grpc but not http.Describe how you solve it
The source of the problem seems to be here. The input is being passed into streaming executor as params instead of a request body. It should either
Use http get with a body. See this link
Use a different http method
Serialize/deserialize the fields before IO.
Environment
Screenshots
Here is a stacktrace: