Skip to content

bug(xtest): post-checkout-java.sh fails silently when pom.xml lacks <properties> section #379

@pflynn-virtru

Description

@pflynn-virtru

Summary

The xtest/sdk/scripts/post-checkout-java.sh script fails silently when processing Java SDK versions (like v0.7.5) where the pom.xml either:

  • Has no <properties> section, or
  • Already has a <platform.branch> reference but not as a defined property

This causes the ${platform.branch} literal string to be passed to buf/git, resulting in build failures.

Root Cause

# Line 37-38: Assumes <properties> exists - silently does nothing if missing
$SED_CMD '/<properties>/a \
      <platform.branch>main</platform.branch>' "$POM_FILE"

# Line 42: ALWAYS runs regardless of whether the property was added
$SED_CMD 's/branch=main/branch=${platform.branch}/g' "$POM_FILE"

Result: branch=main gets replaced with branch=${platform.branch}, but the property is never defined, so Maven passes the literal string to buf.

Error Observed

[exec] Failure: could not clone https://github.com/opentdf/platform.git: exit status 128
[exec] fatal: couldn't find remote ref ${platform.branch}

Affected Versions

  • Java SDK v0.7.5 (LTS)
  • Potentially other older versions without a <properties> section

Suggested Fixes

Option A: Add <properties> section if missing

if ! grep -q "<properties>" "$POM_FILE"; then
  echo "No <properties> section in $POM_FILE, adding one..."
  # Insert <properties> section after <project> or appropriate location
fi

Option B: Only replace branch=main if property was successfully added

if grep -q "<platform.branch>main</platform.branch>" "$POM_FILE"; then
  $SED_CMD 's/branch=main/branch=${platform.branch}/g' "$POM_FILE"
else
  echo "Warning: Could not add platform.branch property to $POM_FILE, skipping replacement"
fi

Option C: Use robust XML editing tool

xmlstarlet ed -s "/project/properties" -t elem -n "platform.branch" -v "main" "$POM_FILE"

References

Impact

This blocks X-Test runs from completing successfully when testing against Java SDK LTS versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions