From a6f9c935a29b39609ec2af4f89e66413264039dd Mon Sep 17 00:00:00 2001 From: Wes Date: Thu, 7 Dec 2023 12:29:39 -0700 Subject: [PATCH] fix: kotlin schema extract request regex (#715) If a verb to verb request object had multiple parameters the regex would capture the last found match. This would result in the matcher finding something like `ages = ...` instead of `TimeRequest` With a call like this, the regex would find `ages = listOf(1, 2, 3)` for the `req` instead of `TimeRequest` ```kotlin val response = context.call(TimeModuleClient::time, TimeRequest(name = req.name ?: "anonymous", ages = listOf(1, 2, 3))) ``` --- .../kotlin/xyz/block/ftl/schemaextractor/ExtractSchemaRule.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-runtime/ftl-runtime/src/main/kotlin/xyz/block/ftl/schemaextractor/ExtractSchemaRule.kt b/kotlin-runtime/ftl-runtime/src/main/kotlin/xyz/block/ftl/schemaextractor/ExtractSchemaRule.kt index 57934cd6f6..926c3dcbce 100644 --- a/kotlin-runtime/ftl-runtime/src/main/kotlin/xyz/block/ftl/schemaextractor/ExtractSchemaRule.kt +++ b/kotlin-runtime/ftl-runtime/src/main/kotlin/xyz/block/ftl/schemaextractor/ExtractSchemaRule.kt @@ -390,7 +390,7 @@ class SchemaExtractor( ) private fun getCallMatcher(ctxVarName: String): Regex { - return """${ctxVarName}.call\((?[^)]+),(?[^)]+)\(.*\)\)""".toRegex(RegexOption.IGNORE_CASE) + return """${ctxVarName}\.call\((?[^,]+),\s*(?[^,]+?)\s*\(""".toRegex(RegexOption.IGNORE_CASE) } private fun KotlinType.toClassDescriptor(): ClassDescriptor =