Skip to content

Conversation

@VGoncharova
Copy link
Contributor

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Oct 28, 2025

Walkthrough

This change modifies the EAP Gradle build triggering mechanism by replacing BOM availability verification with a streamlined Maven metadata lookup that extracts the latest Ktor EAP version, eliminating retries, HTTP status checks, and fallback logic.

Changes

Cohort / File(s) Change Summary
EAP Version Resolution Refactoring
.teamcity/src/subprojects/train/TriggerProjectSamplesOnEAP.kt
Removed BOM availability verification block and helper logic; replaced with direct Maven metadata fetching that extracts the <latest> value and sets env.KTOR_VERSION and ktor.eap.version build parameters. Eliminates retries, explicit HTTP status checks, and fallback branches. Reports chosen version via build status.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay close attention to the Maven metadata extraction logic and handling of the <latest> value
  • Verify the new parameter setting mechanism (env.KTOR_VERSION and ktor.eap.version) integrates correctly with downstream build steps
  • Ensure removal of retry and fallback logic doesn't introduce failure scenarios previously handled

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "remove redundant scripts for BOM availability and EAP version extraction" directly aligns with the main changes described in the raw summary. The changeset removes a BOM availability verification block and replaces it with a streamlined mechanism for EAP version extraction, which is precisely what the title conveys. The title is concise, clear, and specific enough to convey the primary change without unnecessary details, making it an accurate and helpful summary of the changeset.
Description Check ✅ Passed No pull request description was provided by the author. Since the check is described as very lenient and should pass as long as the description is not completely off-topic, an absent description does not violate this criterion. An empty description is not off-topic or unrelated to the changeset; it simply lacks any information, which is acceptable under the lenient standards specified.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch vgoncharova/ktor-train

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
.teamcity/src/subprojects/train/TriggerProjectSamplesOnEAP.kt (2)

418-423: Consider adding retry logic for network resilience.

The createEAPGradleInitScript() function (line 36) uses --retry 2 --retry-delay 2 for fetching the plugin version, which provides resilience against transient network failures. The version resolver script could benefit from similar retry logic to ensure reliable EAP version resolution.

Apply this diff to add retry logic:

             # Download the metadata file
-            if ! curl -s "${'$'}METADATA_URL" -o "${'$'}TEMP_FILE"; then
+            if ! curl -fsSL --connect-timeout 5 --max-time 15 --retry 2 --retry-delay 2 "${'$'}METADATA_URL" -o "${'$'}TEMP_FILE"; then
                 echo "Failed to download metadata from ${'$'}METADATA_URL"
                 rm -f "${'$'}TEMP_FILE"
                 exit 1
             fi

416-416: Ensure temp file cleanup on early exit.

With set -e at line 409, the script will exit immediately on any error. If an error occurs between creating the temp file (line 416) and the cleanup (line 430), the temp file will not be removed, potentially accumulating over time.

Use a trap to guarantee cleanup:

             # Create a temporary file for the metadata
             TEMP_FILE=$(mktemp)
+            trap 'rm -f "$TEMP_FILE"' EXIT
             
             # Download the metadata file
             if ! curl -s "${'$'}METADATA_URL" -o "${'$'}TEMP_FILE"; then
                 echo "Failed to download metadata from ${'$'}METADATA_URL"
-                rm -f "${'$'}TEMP_FILE"
                 exit 1
             fi
             
             # Extract the latest version using grep and sed
             # This pattern looks for a <latest>version</latest> tag
             LATEST_VERSION=$(grep -o '<latest>[^<]*</latest>' "${'$'}TEMP_FILE" | sed 's/<latest>\(.*\)<\/latest>/\1/')
             
-            # Clean up temp file
-            rm -f "${'$'}TEMP_FILE"
-            
             if [ -z "${'$'}LATEST_VERSION" ]; then

Also applies to: 430-430

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d5e78d and 2fa3607.

📒 Files selected for processing (1)
  • .teamcity/src/subprojects/train/TriggerProjectSamplesOnEAP.kt (1 hunks)

Comment on lines +425 to +427
# Extract the latest version using grep and sed
# This pattern looks for a <latest>version</latest> tag
LATEST_VERSION=$(grep -o '<latest>[^<]*</latest>' "${'$'}TEMP_FILE" | sed 's/<latest>\(.*\)<\/latest>/\1/')
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

XML parsing with grep/sed is fragile and may fail on formatted XML.

The pattern '<latest>[^<]*</latest>' assumes the XML tag is on a single line. Maven metadata XML is often formatted with newlines and indentation, which will cause this grep pattern to fail. This could break the version resolution for EAP builds.

Consider using a more robust approach:

-            # Extract the latest version using grep and sed
-            # This pattern looks for a <latest>version</latest> tag
-            LATEST_VERSION=$(grep -o '<latest>[^<]*</latest>' "${'$'}TEMP_FILE" | sed 's/<latest>\(.*\)<\/latest>/\1/')
+            # Extract the latest version using sed with multiline support
+            # This handles XML formatted across multiple lines
+            LATEST_VERSION=$(sed -n 's/.*<latest>\(.*\)<\/latest>.*/\1/p' "${'$'}TEMP_FILE" | tr -d '[:space:]')

Or for more robustness, use xmllint if available:

-            # Extract the latest version using grep and sed
-            # This pattern looks for a <latest>version</latest> tag
-            LATEST_VERSION=$(grep -o '<latest>[^<]*</latest>' "${'$'}TEMP_FILE" | sed 's/<latest>\(.*\)<\/latest>/\1/')
+            # Extract the latest version using xmllint or sed fallback
+            if command -v xmllint &> /dev/null; then
+                LATEST_VERSION=$(xmllint --xpath "string(//latest)" "${'$'}TEMP_FILE")
+            else
+                # Fallback to sed that handles multiline XML
+                LATEST_VERSION=$(sed -n 's/.*<latest>\([^<]*\)<\/latest>.*/\1/p' "${'$'}TEMP_FILE" | tr -d '[:space:]' | head -n 1)
+            fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Extract the latest version using grep and sed
# This pattern looks for a <latest>version</latest> tag
LATEST_VERSION=$(grep -o '<latest>[^<]*</latest>' "${'$'}TEMP_FILE" | sed 's/<latest>\(.*\)<\/latest>/\1/')
# Extract the latest version using sed with multiline support
# This handles XML formatted across multiple lines
LATEST_VERSION=$(sed -n 's/.*<latest>\(.*\)<\/latest>.*/\1/p' "${'$'}TEMP_FILE" | tr -d '[:space:]')
Suggested change
# Extract the latest version using grep and sed
# This pattern looks for a <latest>version</latest> tag
LATEST_VERSION=$(grep -o '<latest>[^<]*</latest>' "${'$'}TEMP_FILE" | sed 's/<latest>\(.*\)<\/latest>/\1/')
# Extract the latest version using xmllint or sed fallback
if command -v xmllint &> /dev/null; then
LATEST_VERSION=$(xmllint --xpath "string(//latest)" "${'$'}TEMP_FILE")
else
# Fallback to sed that handles multiline XML
LATEST_VERSION=$(sed -n 's/.*<latest>\([^<]*\)<\/latest>.*/\1/p' "${'$'}TEMP_FILE" | tr -d '[:space:]' | head -n 1)
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants