Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions codeSnippets/snippets/tutorial-kotlin-rpc-app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
kotlin("jvm") version "2.2.0"
kotlin("plugin.serialization") version "2.2.0"
id("io.ktor.plugin") version "3.2.0"
id("org.jetbrains.kotlinx.rpc.plugin") version "0.9.1"
kotlin("jvm") version "2.2.20"
kotlin("plugin.serialization") version "2.2.20"
id("io.ktor.plugin") version "3.3.0"
id("org.jetbrains.kotlinx.rpc.plugin") version "0.10.0"
Comment on lines +2 to +5
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify plugin versions exist and check for security advisories.

The plugin versions have been updated to:

  • Kotlin: 2.2.20
  • Ktor: 3.3.0
  • kotlinx-rpc: 0.10.0

Ensure these versions are valid and check for any associated security advisories.

Run the following script to verify the versions:


🏁 Script executed:

#!/bin/bash
# Verify Kotlin version 2.2.20 exists
echo "=== Checking Kotlin 2.2.20 ==="
curl -s "https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/2.2.20/" | grep -q "2.2.20" && echo "✓ Kotlin 2.2.20 exists" || echo "✗ Kotlin 2.2.20 not found"

# Verify Ktor version 3.3.0 exists
echo -e "\n=== Checking Ktor 3.3.0 ==="
curl -s "https://repo1.maven.org/maven2/io/ktor/ktor-gradle-plugin/3.3.0/" | grep -q "3.3.0" && echo "✓ Ktor 3.3.0 exists" || echo "✗ Ktor 3.3.0 not found"

# Verify kotlinx-rpc version 0.10.0 exists
echo -e "\n=== Checking kotlinx-rpc 0.10.0 ==="
curl -s "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-rpc-krpc-client/0.10.0/" | grep -q "0.10.0" && echo "✓ kotlinx-rpc 0.10.0 exists" || echo "✗ kotlinx-rpc 0.10.0 not found"

# Check for security advisories
echo -e "\n=== Checking for security advisories ==="
gh api graphql -f query='
{
  securityVulnerabilities(first: 10, ecosystem: MAVEN, package: "org.jetbrains.kotlin:kotlin-gradle-plugin") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
      firstPatchedVersion {
        identifier
      }
    }
  }
}'

Length of output: 262


Fix invalid Ktor plugin version: id("io.ktor.plugin") version "3.3.0" is not published on Maven Central. Update to a valid release (see https://repo1.maven.org/maven2/io/ktor/ktor-gradle-plugin/).

🤖 Prompt for AI Agents
In codeSnippets/snippets/tutorial-kotlin-rpc-app/build.gradle.kts around lines 2
to 5, the Ktor Gradle plugin version "3.3.0" is invalid (not published); replace
it with a published release by updating the id("io.ktor.plugin") version to a
valid version from Maven Central (check
https://repo1.maven.org/maven2/io/ktor/ktor-gradle-plugin/ for available
versions) and ensure the chosen version is compatible with the Kotlin and
serialization plugin versions in the file.

}

group = "com.example"
Expand All @@ -14,12 +14,12 @@ repositories {

dependencies {
implementation("io.ktor:ktor-client-cio-jvm")
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-client:0.9.1")
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-client:0.9.1")
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-client:0.10.0")
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-client:0.10.0")
implementation("io.ktor:ktor-server-netty-jvm")
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-server:0.9.1")
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-server:0.9.1")
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-serialization-json:0.9.1")
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-server:0.10.0")
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-server:0.10.0")
implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-serialization-json:0.10.0")
implementation("ch.qos.logback:logback-classic:1.5.18")
testImplementation(kotlin("test"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import kotlinx.rpc.krpc.ktor.client.KtorRpcClient
import kotlinx.rpc.krpc.ktor.client.installKrpc
import kotlinx.rpc.krpc.ktor.client.rpc
import kotlinx.rpc.krpc.ktor.client.rpcConfig
import kotlinx.rpc.krpc.serialization.json.json

fun main() = runBlocking {
val ktorClient = HttpClient {
installKrpc {
waitForServices = true
serialization { json() }
}
}

Expand Down
16 changes: 8 additions & 8 deletions topics/tutorial-first-steps-with-kotlin-rpc.topic
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
and add the following implementation:
<code-block lang="kotlin"
src="snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt"
include-lines="1-13,14-37,39-40,59-60"
include-lines="1-14,15-38,40-41,60-61"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify that the updated line ranges correctly reflect the Client.kt changes.

Multiple include-lines attributes have been updated to account for the new import and serialization configuration in Client.kt. Ensure these line ranges accurately match the intended code sections.

Run the following script to verify the line ranges:

Also applies to: 242-242, 254-254, 263-263, 279-279, 291-291, 497-497, 505-505


🏁 Script executed:

#!/bin/bash
# Extract and display the specified line ranges from Client.kt

echo "=== Lines 1-14 (imports section) ==="
sed -n '1,14p' codeSnippets/snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt

echo -e "\n=== Lines 15-38 (main function setup) ==="
sed -n '15,38p' codeSnippets/snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt

echo -e "\n=== Lines 40-41 (commented pizza order) ==="
sed -n '40,41p' codeSnippets/snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt

echo -e "\n=== Line 60 (client close) ==="
sed -n '60p' codeSnippets/snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt

echo -e "\n=== Lines 43-50 (multiple orders) ==="
sed -n '43,50p' codeSnippets/snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt

echo -e "\n=== Lines 52-58 (collect results) ==="
sed -n '52,58p' codeSnippets/snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt

Length of output: 1817


🏁 Script executed:

#!/bin/bash
topic="topics/tutorial-first-steps-with-kotlin-rpc.topic"
client="codeSnippets/snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt"

# 1. Confirm closing brace at line 61
echo "=== Lines 59-62 (closing brace check) ==="
sed -n '59,62p' "$client"

# 2. For each updated include-lines (topic lines 222,242,254,263,279,291,497,505), extract and display code segments
grep -n 'include-lines="' "$topic" | grep -E ':(222|242|254|263|279|291|497|505):' | while IFS=: read path line attr; do
  ranges=$(echo "$attr" | sed -E 's/.*include-lines="([^"]+)".*/\1/')
  echo -e "\n=== topic:$line → include-lines=\"$ranges\" ==="
  IFS=, read -ra parts <<< "$ranges"
  for r in "${parts[@]}"; do
    echo "--- Client.kt lines $r ---"
    sed -n "${r}p" "$client"
  done
done

Length of output: 67


🏁 Script executed:

#!/bin/bash
grep -n 'include-lines=' topics/tutorial-first-steps-with-kotlin-rpc.topic

Length of output: 1035


🏁 Script executed:

#!/bin/bash
client="codeSnippets/snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt"

echo "=== Lines 17-21 ==="
sed -n '17,21p' "$client"

echo -e "\n=== Lines 23-35 ==="
sed -n '23,35p' "$client"

echo -e "\n=== Line 37 ==="
sed -n '37p' "$client"

echo -e "\n=== Lines 40-41 ==="
sed -n '40,41p' "$client"

echo -e "\n=== Lines 43-50 ==="
sed -n '43,50p' "$client"

echo -e "\n=== Lines 52-58 ==="
sed -n '52,58p' "$client"

echo -e "\n=== Line 60 ==="
sed -n '60p' "$client"

Length of output: 1207


🏁 Script executed:

#!/bin/bash
sed -n '230,260p' topics/tutorial-first-steps-with-kotlin-rpc.topic

Length of output: 1874


Update runBlocking snippet range
In topics/tutorial-first-steps-with-kotlin-rpc.topic at the snippet on line 242, change include-lines="16,61" to include-lines="15,61" so the runBlocking invocation (fun main() = runBlocking {) is shown.

🤖 Prompt for AI Agents
In topics/tutorial-first-steps-with-kotlin-rpc.topic around lines 222 to 222,
the snippet include-lines attribute currently uses "16,61" which omits the
runBlocking invocation; update the include-lines value to "15,61" so the snippet
shows the `fun main() = runBlocking {` line.

/>
</step>
</procedure>
Expand All @@ -239,7 +239,7 @@
</p>
<code-block lang="kotlin"
src="snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt"
include-lines="15,60"
include-lines="16,61"
/>
<tip>
Note that <code>runBlocking</code> is designed for spikes and tests, rather than production code.
Expand All @@ -251,7 +251,7 @@
</p>
<code-block lang="kotlin"
src="snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt"
include-lines="16-20"
include-lines="17-21"
/>
<p>
Having created this Ktor client, you then create a <code>KtorRpcClient</code> object for invoking remote
Expand All @@ -260,7 +260,7 @@
</p>
<code-block lang="kotlin"
src="snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt"
include-lines="22-34"
include-lines="23-35"
/>
<p>
At this point, the standard setup has been completed, and you are ready to use the functionality
Expand All @@ -276,7 +276,7 @@
</p>
<code-block lang="kotlin"
src="snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt"
include-lines="39-40"
include-lines="40-41"
/>
<p>
Note that a tremendous amount of work is being done for you at this point. The details of the call and
Expand All @@ -288,7 +288,7 @@
</p>
<code-block lang="kotlin"
src="snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt"
include-lines="59"
include-lines="60"
/>
</chapter>
<chapter title="Implement the server" id="server-implementation">
Expand Down Expand Up @@ -494,15 +494,15 @@
file, submit multiple orders using two different client IDs:
<code-block lang="kotlin"
src="snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt"
include-lines="36,42-49"
include-lines="37,43-50"
/>
<p>
Then you iterate over the results, using the <code>Coroutines</code> library and
<code>collect</code> method:
</p>
<code-block lang="kotlin"
src="snippets/tutorial-kotlin-rpc-app/src/main/kotlin/Client.kt"
include-lines="51-57"
include-lines="52-58"
/>
</step>
<step>
Expand Down