yggdrasil does not dispatch, when worker is remote content mode
jirihnidek opened this issue · comments
Describe the bug
When e.g. echo worker works in remote content mode, then dispatching message with URL does not work, because URL is not considered as valid JSON document. Contrary when URL is send encapsulated by quotation marks, then it is not valid URL.
To Reproduce
Steps to reproduce the behavior:
- Start yggdrasil using:
go run ./cmd/yggd --server tcp://localhost:1883 --log-level trace --client-id $(hostname)
- Start echo worker using in remote content mode:
go run ./worker/echo -log-level trace -remote-content
- Send some URL in MQTT message:
echo 'http://localhost/robots.txt' | go run ./cmd/yggctl generate data-message --directive echo - | pub -broker tcp://localhost:1883 -topic yggdrasil/$(hostname)/data/in
Or try to run:echo '"http://localhost/robots.txt"' | go run ./cmd/yggctl generate data-message --directive echo - | pub -broker tcp://localhost:1883 -topic yggdrasil/$(hostname)/data/in
Expected behavior
yggdrasil tries to get data from given URL and it is dispatched to the worker.
Actual behavior
3.1
[yggd] 2024/02/20 11:36:42 /home/jhnidek/github/redhat-insights/yggdrasil/internal/transport/mqtt.go:72: cannot receive data message: cannot unmarshal data message: unexpected end of JSON input
3.2
[yggd] 2024/02/19 16:53:57 /home/jhnidek/github/redhat-insights/yggdrasil/internal/work/dispatcher.go:185: cannot dispatch data: cannot parse content as URL: parse ""http://localhost/robots.txt\"": first path segment in URL cannot contain colon
Additional Information
- Latest version of main branch
- This issue was introduced in this PR: #205
Good catch. "Remote content" mode already makes assumptions about the format and value of the message content already, so we could assume it contains a JSON string fragment and a URL. That way we can first unmarshal it to JSON and then parse the JSON string as a URL. Would that work?