summaryrefslogtreecommitdiff
path: root/nexus
diff options
context:
space:
mode:
authorMS <ms@taler.net>2021-01-08 23:57:54 +0100
committerMS <ms@taler.net>2021-01-29 10:48:30 +0100
commit356314701a0d447259dc5d4624e2d2d17154d8a5 (patch)
tree87f994c13d1b66ae4911b0d3c8ed40c3cd55c87e /nexus
parent193cd59750fdbb0bcdeaefaefc771adb2f5e11a7 (diff)
downloadlibeufin-356314701a0d447259dc5d4624e2d2d17154d8a5.tar.gz
libeufin-356314701a0d447259dc5d4624e2d2d17154d8a5.tar.bz2
libeufin-356314701a0d447259dc5d4624e2d2d17154d8a5.zip
make sure 400 is responded when JSON is invalid
Diffstat (limited to 'nexus')
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt12
1 files changed, 8 insertions, 4 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index 69f13f53..2c6fe7d6 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -469,8 +469,13 @@ fun serverMain(dbName: String, host: String, port: Int) {
// sanity checks.
when (schedSpec.type) {
"fetch" -> {
- jacksonObjectMapper().treeToValue(schedSpec.params, FetchSpecJson::class.java)
- ?: throw NexusError(HttpStatusCode.BadRequest, "bad fetch spec")
+ // only checking validity.
+ try {
+ jacksonObjectMapper().treeToValue(schedSpec.params, FetchSpecJson::class.java)
+ } catch (e: Exception) {
+ logger.error(e.message)
+ throw NexusError(HttpStatusCode.BadRequest, "bad fetch spec")
+ }
}
"submit" -> {
}
@@ -491,8 +496,7 @@ fun serverMain(dbName: String, host: String, port: Int) {
this.taskCronspec = schedSpec.cronspec
this.taskName = requireValidResourceName(schedSpec.name)
this.taskType = schedSpec.type
- this.taskParams =
- jacksonObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(schedSpec.params)
+ this.taskParams = jacksonObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(schedSpec.params)
}
}
call.respond(object {})