golemcloud / golem

Golem is an open source durable computing platform that makes it easy to build and deploy highly reliable distributed systems.
https://learn.golem.cloud/
Apache License 2.0
218 stars 22 forks source link

Issue with adding headers to the response in API definitions #688

Closed vigoo closed 1 month ago

vigoo commented 2 months ago

From https://discord.com/channels/1134448700572319785/1134448701260169249/1264231231017717840

Hi all! I've been playing with the API definition format, but I have a problem: when I try to add headers to the response, I get an empty body instead. Basically, I've defined my response like this:

        "response": "${ {body: golem:component/api.{get-character}() } }"

and it works (I get a JSON reponse from the worker); but when I change it to something like:

        "response": "${ {body: golem:component/api.{get-character}(), headers: { x-test: 'foobar' } } }"

then I get nothing:

> http GET http://localhost:9006/1/character Accept=application/json -phH
GET /1/character HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 30
Content-Type: application/json
Host: localhost:9006
User-Agent: HTTPie/3.2.2

HTTP/1.1 200 OK
content-length: 0
date: Sat, 20 Jul 2024 14:13:08 GMT

Has anyone stubled upon this problem? I've checked the issues but I couldn't find anything related. Thanks!

(edit: forgot to add link to reproducible example: https://github.com/albx79/golem-experiments/tree/main/fate-api)

justcoon commented 1 month ago

in relation to Web Assembly Value Encoding, we changed ' to ", parsing did not failed on ', but expression evaluation ended with empty expression, which resulted in Unit/Empty response