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

fix: decode url param in relay rest API #862

Merged
merged 5 commits into from
Nov 6, 2023
Merged

Conversation

chaitanyaprem
Copy link
Collaborator

Description

Topic URL param is not being read properly in relay REST APIs which is causing 500 error.

Hi, I'm trying to use relay via REST API in go-waku (wakuorg/go-waku:latest) as described here https://nagyzoltanpeter.github.io/nwaku-api/index.html#post-/relay/v1/subscriptions but I get errors for relay/v1/messages endpoint
 For example trying to publish a message I get a 500
 curl -vv -X POST "http://127.0.0.1:63970/relay/v1/messages/%2Fwaku%2F2%2Fdefault-waku%2Fproto" -H "content-type: application/json" -d '{"payload":"ZXhhbXBsZQ==","contentTopic":"string","version":0,"timestamp":0}'
 When querying messages I get 404 with not subscribed to topic
 curl -vv -X GET "http://127.0.0.1:63970/relay/v1/messages/%2Fwaku%2F2%2Fdefault-waku%2Fproto" -H "accept: application/json" 
 
If I use nwaku instead of gowaku it works fine. Also If I use gowaku with RPC instead of REST it works fine so the container setup seems correct. 
Also trying to subscribe the node to a topic seems to work fine, I get 200 here:
curl -vv -X POST "http://127.0.0.1:63970/relay/v1/subscriptions" -H "accept: text/plain" -H "content-type: application/json" -d '["/waku/2/default-waku/proto"]' 

Changes

  • decode URL param for post and get messages relay REST API

Tests

Verified both the APIs with /waku/2/default-waku/proto topic and they seem to work fine.

@status-im-auto
Copy link

status-im-auto commented Nov 3, 2023

Jenkins Builds

Click to see older builds (18)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ b196d91 #1 2023-11-03 10:21:32 ~1 min nix-flake 📄log
✔️ b196d91 #1 2023-11-03 10:22:39 ~2 min linux 📦deb
✔️ b196d91 #1 2023-11-03 10:23:21 ~3 min tests 📄log
✔️ b196d91 #1 2023-11-03 10:23:28 ~3 min tests 📄log
✔️ b196d91 #1 2023-11-03 10:23:58 ~4 min android 📦tgz
✔️ b196d91 #1 2023-11-03 10:24:08 ~4 min ios 📦tgz
✔️ 3f293af #2 2023-11-03 12:34:11 ~3 min ios 📦tgz
✔️ 3f293af #2 2023-11-03 12:38:58 ~8 min nix-flake 📄log
✔️ 3f293af #2 2023-11-03 12:39:03 ~8 min linux 📦deb
✔️ 3f293af #2 2023-11-03 12:40:18 ~9 min android 📦tgz
✔️ 3f293af #2 2023-11-03 12:41:43 ~11 min tests 📄log
✔️ 3f293af #2 2023-11-03 12:43:22 ~12 min tests 📄log
✔️ 5699176 #3 2023-11-06 07:30:24 ~2 min nix-flake 📄log
✔️ 5699176 #3 2023-11-06 07:30:52 ~2 min linux 📦deb
✔️ 5699176 #3 2023-11-06 07:31:43 ~3 min tests 📄log
✔️ 5699176 #3 2023-11-06 07:31:48 ~3 min ios 📦tgz
✔️ 5699176 #3 2023-11-06 07:31:51 ~3 min android 📦tgz
✔️ 5699176 #3 2023-11-06 07:32:01 ~3 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 1e6aa83 #4 2023-11-06 07:54:37 ~1 min tests 📄log
✔️ 1e6aa83 #4 2023-11-06 07:54:43 ~1 min linux 📦deb
✔️ 1e6aa83 #4 2023-11-06 07:55:25 ~1 min nix-flake 📄log
✔️ 1e6aa83 #4 2023-11-06 07:55:47 ~2 min tests 📄log
✔️ 1e6aa83 #4 2023-11-06 07:57:32 ~4 min android 📦tgz
✔️ 1e6aa83 #4 2023-11-06 07:57:41 ~4 min ios 📦tgz
✔️ 154767d #5 2023-11-06 07:55:49 ~1 min linux 📦deb
✖️ 154767d #5 2023-11-06 07:56:57 ~1 min tests 📄log
✔️ 154767d #5 2023-11-06 07:57:33 ~2 min nix-flake 📄log
✔️ 154767d #5 2023-11-06 07:58:41 ~4 min ios 📦tgz
✔️ 154767d #5 2023-11-06 07:58:42 ~3 min tests 📄log
✔️ 154767d #5 2023-11-06 08:01:13 ~3 min android 📦tgz
✔️ 154767d #6 2023-11-06 08:32:41 ~3 min tests 📄log

Co-authored-by: richΛrd <info@richardramos.me>
Copy link
Contributor

@harsh-98 harsh-98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice change.

func writeGetMessageErr(w http.ResponseWriter, err error, code int, logger *zap.Logger) {
// write status before the body
w.WriteHeader(code)
logger.Error("get message", zap.Error(err))

Check failure

Code scanning / CodeQL

Log entries created from user input High

This log entry depends on a
user-provided value
.
@chaitanyaprem chaitanyaprem merged commit 25eb4d6 into master Nov 6, 2023
1 of 2 checks passed
@chaitanyaprem chaitanyaprem deleted the fix/relay-rest-api branch November 6, 2023 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants