chore: better descriptive log (#2826)

* chore: update logs with topic discription & debug msg

* chore: update unit according to error msg

* chore: update rest unit according to error msg

* chore: add content-topic with debug msg
This commit is contained in:
Darshan K 2024-06-20 18:38:55 +05:30 committed by GitHub
parent c483acee35
commit 94947a8504
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 4 deletions

View File

@ -69,7 +69,7 @@ suite "Waku Message - Content topics namespacing":
let err = ns.tryError()
check:
err.kind == ParsingErrorKind.InvalidFormat
err.cause == "topic must start with slash"
err.cause == "content-topic '" & topic & "' must start with slash"
test "Parse content topic string - Invalid string: not namespaced":
## Given

View File

@ -511,11 +511,12 @@ suite "Waku v2 Rest API - Relay":
let client = newRestHttpClient(initTAddress(restAddress, restPort))
let invalidContentTopic = "invalidContentTopic"
# When
let response = await client.relayPostAutoMessagesV1(
RelayWakuMessage(
payload: base64.encode("TEST-PAYLOAD"),
contentTopic: some("invalidContentTopic"),
contentTopic: some(invalidContentTopic),
timestamp: some(int64(2022)),
)
)
@ -525,7 +526,8 @@ suite "Waku v2 Rest API - Relay":
response.status == 400
$response.contentType == $MIMETYPE_TEXT
response.data ==
"Failed to publish. Autosharding error: invalid format: topic must start with slash"
"Failed to publish. Autosharding error: invalid format: content-topic '" &
invalidContentTopic & "' must start with slash"
await restServer.stop()
await restServer.closeWait()

View File

@ -149,6 +149,9 @@ proc setupProtocols(
conf.contentTopics.mapIt(node.wakuSharding.getShard(it).expect("Valid Shard"))
let pubsubTopics = conf.pubsubTopics & shards
debug "Shards created from content topics",
contentTopics = conf.contentTopics, shards = shards
let parsedMaxMsgSize = parseMsgSize(conf.maxMessageSize).valueOr:
return err("failed to parse 'max-num-bytes-msg-size' param: " & $error)

View File

@ -68,7 +68,9 @@ proc parse*(
## Autosharding adds 1 optional prefix `/<gen#>
if not topic.startsWith("/"):
return err(ParsingError.invalidFormat("topic must start with slash"))
return err(
ParsingError.invalidFormat("content-topic '" & topic & "' must start with slash")
)
let parts = topic[1 ..< topic.len].split("/")