Skip to content

Fix consecutive hyphens in export id#6194

Merged
oeyh merged 1 commit into
opensearch-project:mainfrom
oeyh:rds/fix-export-id-bug
Oct 23, 2025
Merged

Fix consecutive hyphens in export id#6194
oeyh merged 1 commit into
opensearch-project:mainfrom
oeyh:rds/fix-export-id-bug

Conversation

@oeyh

@oeyh oeyh commented Oct 22, 2025

Copy link
Copy Markdown
Collaborator

Description

Fixed the RDS export task ID generation to prevent consecutive hyphens in export task identifiers that cause RDS validation failures.

Issues Resolved

Resolves #6186

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Hai Yan <oeyh@amazon.com>
return truncateString(snapshotId, EXPORT_TASK_ID_MAX_LENGTH - 16) + "-export-" + UUID.randomUUID().toString().substring(0, 8);
String truncatedSnapshotId = truncateString(snapshotId, EXPORT_TASK_ID_MAX_LENGTH - 16);
// Remove trailing hyphens to prevent consecutive hyphens in the export task identifier
truncatedSnapshotId = truncatedSnapshotId.replaceAll("-+$", "");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think using "replaceAll" is expensive due to regular expressions. You can use either

  1. a while loop like
int endIndex = truncatedSnapshotId.length();
while (endIndex > 0 && truncatedSnapshotId.charAt(endIndex - 1) == '-') {
    endIndex--;
}
truncatedSnapshotId = truncatedSnapshotId.substring(0, endIndex);

or use Apache StringUtils like this

import org.apache.commons.lang3.StringUtils;

truncatedSnapshotId = StringUtils.stripEnd(truncatedSnapshotId, "-");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Creating an export only happens once per database. I think this is fine.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this runs only once when pipeline starts.

return truncateString(snapshotId, EXPORT_TASK_ID_MAX_LENGTH - 16) + "-export-" + UUID.randomUUID().toString().substring(0, 8);
String truncatedSnapshotId = truncateString(snapshotId, EXPORT_TASK_ID_MAX_LENGTH - 16);
// Remove trailing hyphens to prevent consecutive hyphens in the export task identifier
truncatedSnapshotId = truncatedSnapshotId.replaceAll("-+$", "");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Creating an export only happens once per database. I think this is fine.

String truncatedSnapshotId = truncateString(snapshotId, EXPORT_TASK_ID_MAX_LENGTH - 16);
// Remove trailing hyphens to prevent consecutive hyphens in the export task identifier
truncatedSnapshotId = truncatedSnapshotId.replaceAll("-+$", "");
return truncatedSnapshotId + "-export-" + UUID.randomUUID().toString().substring(0, 8);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are there any other export restrictions which we might hit?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These are the naming restrictions:

  • Identifiers must begin with a letter;
  • must contain only ASCII letters, digits, and hyphens;
  • and must not end with a hyphen or contain two consecutive hyphens.
  • cannot be longer than 60 characters

The snapshot Id, which is used as first part of the export id here, conforms to similar rules, so after truncating and preventing consecutive hyphens, we should be good.

@oeyh oeyh merged commit daeac45 into opensearch-project:main Oct 23, 2025
44 of 47 checks passed
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.

[BUG]Special Aurora Postgres name caused the pipeline to fail in creating rds.export.ExportTask.

3 participants