diff options
author | MS <ms@taler.net> | 2021-01-08 23:57:54 +0100 |
---|---|---|
committer | MS <ms@taler.net> | 2021-01-29 10:48:30 +0100 |
commit | 356314701a0d447259dc5d4624e2d2d17154d8a5 (patch) | |
tree | 87f994c13d1b66ae4911b0d3c8ed40c3cd55c87e /nexus | |
parent | 193cd59750fdbb0bcdeaefaefc771adb2f5e11a7 (diff) | |
download | libeufin-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.kt | 12 |
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 {}) |