mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-04-14 04:03:20 +00:00
Add pre-check of options used in config Json for logos-delivery-api pre-createNode, treat unrecognized options as error
This commit is contained in:
parent
59bd365c16
commit
487832e662
@ -1,4 +1,4 @@
|
||||
import std/[json, strutils]
|
||||
import std/[json, strutils, sets]
|
||||
import chronos, chronicles, results, confutils, confutils/std/net, ffi
|
||||
import
|
||||
waku/factory/waku,
|
||||
@ -28,6 +28,16 @@ registerReqFFI(CreateNodeRequest, ctx: ptr FFIContext[Waku]):
|
||||
" configJson string: " & $configJson
|
||||
)
|
||||
|
||||
# Collect known fields
|
||||
var knownFields = initHashSet[string]()
|
||||
for confField, _ in fieldPairs(conf):
|
||||
knownFields.incl(confField)
|
||||
# Check for unknown keys
|
||||
for key in jsonNode.keys:
|
||||
if key notin knownFields:
|
||||
error "Invalid configuration option found.", option = key
|
||||
return err("Invalid configuration option found: " & key)
|
||||
|
||||
for confField, confValue in fieldPairs(conf):
|
||||
if jsonNode.contains(confField):
|
||||
let formattedString = ($jsonNode[confField]).strip(chars = {'\"'})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user