Skip to content

Commit 5bfbe93

Browse files
committed
Fix stray fragment injection in updateVersion gradle task
When appending the current version to the rolling-upgrade BWC list, the rolling section was sliced from updatedContent using a stale offset. Updating the restart-upgrade section beforehand changed the string length, so the stale offset pointed before the rolling job header and captured the tail of the preceding line, injecting an invalid fragment into the workflow YAML. Recompute the offset inline when extracting the rolling section, matching the pattern used by the equivalent task in the search-relevance repo. Signed-off-by: Heemin Kim <heemin@amazon.com>
1 parent d35bab4 commit 5bfbe93

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,15 +689,16 @@ task updateVersion {
689689
println "Added ${currentVersionWithoutSnapshot} to Restart-Upgrade BWC version list"
690690
}
691691

692-
// Extract and update Rolling-Upgrade section
693-
def rollingSection = updatedContent.substring(rollingStart)
692+
// Extract and update Rolling-Upgrade section.
693+
// Recompute the offset inline, since updating the restart section above may have
694+
// changed the length of updatedContent and invalidated rollingStart.
695+
def rollingSection = updatedContent.substring(updatedContent.indexOf('Rolling-Upgrade-BWCTests-NeuralSearch:'))
694696
def rollingVersions = extractVersions(rollingSection)
695697
if (!rollingVersions.isEmpty() && isCurrentVersionNewer(rollingVersions.last())) {
696698
def updatedRollingSection = rollingSection.replaceFirst(
697699
/(?m)(^\s*bwc_version:\s*\[([^\]]+))\]/,
698700
"\$1, \"${currentVersionWithoutSnapshot}\"]"
699701
)
700-
// Need to recalculate rollingStart in case the restart section changed
701702
def newRollingStart = updatedContent.indexOf('Rolling-Upgrade-BWCTests-NeuralSearch:')
702703
updatedContent = updatedContent.substring(0, newRollingStart) + updatedRollingSection
703704
println "Added ${currentVersionWithoutSnapshot} to Rolling-Upgrade BWC version list"

0 commit comments

Comments
 (0)