Skip to content

Commit

Permalink
Merge 08b033f into 650a948
Browse files Browse the repository at this point in the history
  • Loading branch information
NagyZoltanPeter authored Dec 10, 2024
2 parents 650a948 + 08b033f commit 0e1f311
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion apps/liteprotocoltester/tester_message.nim
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ proc readValue*(
)
size = some(reader.readValue(uint64))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if sender.isNone():
reader.raiseUnexpectedValue("Field `sender` is missing")
Expand Down
2 changes: 1 addition & 1 deletion vendor/nimbus-build-system
8 changes: 4 additions & 4 deletions waku/waku_api/rest/admin/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ proc readValue*(
)
connected = some(reader.readValue(bool))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if connected.isNone():
reader.raiseUnexpectedValue("Field `connected` is missing")
Expand Down Expand Up @@ -116,7 +116,7 @@ proc readValue*(
reader.raiseUnexpectedField("Multiple `origin` fields found", "WakuPeer")
origin = some(reader.readValue(PeerOrigin))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if multiaddr.isNone():
reader.raiseUnexpectedValue("Field `multiaddr` is missing")
Expand Down Expand Up @@ -153,7 +153,7 @@ proc readValue*(
)
contentTopic = some(reader.readValue(string))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if pubsubTopic.isNone():
reader.raiseUnexpectedValue("Field `pubsubTopic` is missing")
Expand Down Expand Up @@ -185,7 +185,7 @@ proc readValue*(
)
filterCriteria = some(reader.readValue(seq[FilterTopic]))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if peerId.isNone():
reader.raiseUnexpectedValue("Field `peerId` is missing")
Expand Down
3 changes: 2 additions & 1 deletion waku/waku_api/rest/debug/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import chronicles, json_serialization, json_serialization/std/options
import ../../../waku_node, ../serdes
import std/typetraits

#### Types

Expand Down Expand Up @@ -47,7 +48,7 @@ proc readValue*(
reader.raiseUnexpectedField("Multiple `enrUri` fields found", "DebugWakuInfo")
enrUri = some(reader.readValue(string))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if listenAddresses.isNone():
reader.raiseUnexpectedValue("Field `listenAddresses` is missing")
Expand Down
14 changes: 7 additions & 7 deletions waku/waku_api/rest/filter/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ proc readValue*(
of "ephemeral":
ephemeral = some(reader.readValue(bool))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if payload.isNone():
reader.raiseUnexpectedValue("Field `payload` is missing")
Expand Down Expand Up @@ -225,7 +225,7 @@ proc readValue*(
of "contentFilters":
contentFilters = some(reader.readValue(seq[ContentTopic]))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if contentFilters.isNone():
reader.raiseUnexpectedValue("Field `contentFilters` is missing")
Expand Down Expand Up @@ -262,7 +262,7 @@ proc readValue*(
of "requestId":
requestId = some(reader.readValue(string))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if requestId.isNone():
reader.raiseUnexpectedValue("Field `requestId` is missing")
Expand Down Expand Up @@ -296,7 +296,7 @@ proc readValue*(
of "contentFilters":
contentFilters = some(reader.readValue(seq[ContentTopic]))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if requestId.isNone():
reader.raiseUnexpectedValue("Field `requestId` is missing")
Expand Down Expand Up @@ -344,7 +344,7 @@ proc readValue*(
of "contentFilters":
contentFilters = some(reader.readValue(seq[ContentTopic]))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if requestId.isNone():
reader.raiseUnexpectedValue("Field `requestId` is missing")
Expand Down Expand Up @@ -385,7 +385,7 @@ proc readValue*(
of "requestId":
requestId = some(reader.readValue(string))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if requestId.isNone():
reader.raiseUnexpectedValue("Field `requestId` is missing")
Expand Down Expand Up @@ -416,7 +416,7 @@ proc readValue*(
of "statusDesc":
statusDesc = some(reader.readValue(string))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if requestId.isNone():
reader.raiseUnexpectedValue("Field `requestId` is missing")
Expand Down
2 changes: 1 addition & 1 deletion waku/waku_api/rest/health/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ proc readValue*(

protocolsHealth = some(reader.readValue(seq[ProtocolHealth]))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if nodeHealth.isNone():
reader.raiseUnexpectedValue("Field `nodeHealth` is missing")
Expand Down
2 changes: 1 addition & 1 deletion waku/waku_api/rest/lightpush/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ proc readValue*(
of "message":
message = some(reader.readValue(RelayWakuMessage))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if message.isNone():
reader.raiseUnexpectedValue("Field `message` is missing")
Expand Down
2 changes: 1 addition & 1 deletion waku/waku_api/rest/relay/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ proc readValue*(
of "ephemeral":
ephemeral = some(reader.readValue(bool))
else:
unrecognizedFieldWarning()
unrecognizedFieldWarning(value)

if payload.isNone() or isEmptyOrWhitespace(string(payload.get())):
reader.raiseUnexpectedValue("Field `payload` is missing or empty")
Expand Down
4 changes: 2 additions & 2 deletions waku/waku_api/rest/serdes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ createJsonFlavor RestJson

Json.setWriter JsonWriter, PreferredOutput = string

template unrecognizedFieldWarning*() =
template unrecognizedFieldWarning*(field: typed) =
# TODO: There should be a different notification mechanism for informing the
# caller of a deserialization routine for unexpected fields.
# The chonicles import in this module should be removed.
debug "JSON field not recognized by the current version of nwaku. Consider upgrading",
fieldName, typeName = typetraits.name(typeof value)
fieldName, typeName = typetraits.name(typeof field)

type SerdesResult*[T] = Result[T, cstring]

Expand Down

0 comments on commit 0e1f311

Please sign in to comment.