Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yggdrasil does not dispatch, when worker is remote content mode #208

Open
jirihnidek opened this issue Feb 20, 2024 · 2 comments
Open

yggdrasil does not dispatch, when worker is remote content mode #208

jirihnidek opened this issue Feb 20, 2024 · 2 comments

Comments

@jirihnidek
Copy link
Contributor

jirihnidek commented Feb 20, 2024

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:

  1. Start yggdrasil using:
    go run ./cmd/yggd --server tcp://localhost:1883 --log-level trace --client-id $(hostname)
  2. Start echo worker using in remote content mode:
    go run ./worker/echo -log-level trace -remote-content
  3. Send some URL in MQTT message:
    1. 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:
    2. 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

jirihnidek added a commit that referenced this issue Feb 20, 2024
* When worker was in remote content mode, then yggdrasil still
  expects raw data as valid JSON document. URL like:
  http://example.com/ is not valid JSON document. It could be
  e.g. "http://example.com/"
* Not sure if this is the best solution, but it solves the issue
  described in issue #208
@subpop
Copy link
Collaborator

subpop commented Feb 26, 2024

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?

jirihnidek added a commit that referenced this issue Mar 4, 2024
* When worker was in remote content mode, then yggdrasil still
  expects raw data as valid JSON document. URL like:
  http://example.com/ is not valid JSON document. It could be
  e.g. "http://example.com/"
* Solves issue #208
@jirihnidek
Copy link
Contributor Author

@subpop Hi, this issue is fixed in #209 as you proposed.

jirihnidek added a commit that referenced this issue Mar 6, 2024
* When worker was in remote content mode, then yggdrasil still
  expects raw data as valid JSON document. URL like:
  http://example.com/ is not valid JSON document. It could be
  e.g. "http://example.com/"
* Solves issue #208
jirihnidek added a commit that referenced this issue Mar 7, 2024
* When worker was in remote content mode, then yggdrasil still
  expects raw data as valid JSON document. URL like:
  http://example.com/ is not valid JSON document. It could be
  e.g. "http://example.com/"
* Solves issue #208
subpop pushed a commit that referenced this issue Mar 8, 2024
* When worker was in remote content mode, then yggdrasil still
  expects raw data as valid JSON document. URL like:
  http://example.com/ is not valid JSON document. It could be
  e.g. "http://example.com/"
* Solves issue #208
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants