Skip to content

feat: Enhance UUID validation with subaccount ID support#230

Merged
sp1goyal merged 3 commits intoSAP:mainfrom
davirezendegb:patch-1
Feb 4, 2026
Merged

feat: Enhance UUID validation with subaccount ID support#230
sp1goyal merged 3 commits intoSAP:mainfrom
davirezendegb:patch-1

Conversation

@davirezendegb
Copy link
Contributor

@davirezendegb davirezendegb commented Jan 30, 2026

Refactor UUID validation to include SAP BTP short subaccount ID format.
Could you make the correction? Because there are sub-accounts that are managed by SAP and do not contain a large UUID.

Refactor UUID validation to include SAP BTP short subaccount ID format.
@cla-assistant
Copy link

cla-assistant bot commented Jan 30, 2026

CLA assistant check
All committers have signed the CLA.

@davirezendegb
Copy link
Contributor Author

@sp1goyal

@vipinvkmenon vipinvkmenon changed the title Enhance UUID validation with subaccount ID support feat: Enhance UUID validation with subaccount ID support Feb 2, 2026
@lechnerc77 lechnerc77 added this to the 1.2.0 milestone Feb 3, 2026
@lechnerc77 lechnerc77 added the enhancement New feature or request label Feb 3, 2026
@lechnerc77
Copy link
Member

@davirezendegb Can you sign the CLA agreement? This is a prerequisite for us to accept contributions.

Please also check that the build can be executed successfully (see https://github.com/SAP/terraform-provider-scc/actions/runs/21529053233/job/62243710758?pr=230) and that the documentation is up to date (i.e. execute make generate)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the UUID validator to also accept SAP BTP “short” subaccount IDs so SAP-managed subaccounts without full UUIDs can be used.

Changes:

  • Expands the UuidRegexp pattern to match either a standard UUID or a short subaccount ID ([a-z][0-9a-fA-F]{8}).
  • Updates the validator error message to mention the additional accepted format.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +10 to +18
// UuidRegexp matches:
// - Standard UUID format: 8-4-4-4-12 (hex with hyphens)
// - SAP subaccount ID format: [a-z] + 8 hex characters (e.g. xf014edd7)
var UuidRegexp = regexp.MustCompile(
`^(?:` +
`[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}` +
`|` +
`[a-z][0-9a-fA-F]{8}` +
`)$`,
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

New behavior adds acceptance of the SAP short subaccount ID pattern ([a-z][0-9a-fA-F]{8}), but the package unit tests currently only cover standard UUIDs and a generic mismatch. Add explicit test cases for a valid short subaccount ID and a few invalid variants (wrong length / invalid hex) to prevent regressions.

Copilot uses AI. Check for mistakes.
Comment on lines +21 to 23
// ValidUUID validates that the string attribute value is either
// a standard UUID or a SAP subaccount ID
func ValidUUID() validator.String {
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

ValidUUID (and UuidRegexp) now validates more than UUIDs (it also accepts SAP short subaccount IDs). To avoid confusion for future uses, consider introducing a more accurately named validator (e.g., ValidSubaccountID / ValidSubaccountIdentifier) and either migrate call sites or keep ValidUUID as a backwards-compatible alias.

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +27
// ValidUUID validates that the string attribute value is either
// a standard UUID or a SAP subaccount ID
func ValidUUID() validator.String {
return stringvalidator.RegexMatches(UuidRegexp, "value must be a valid UUID")
return stringvalidator.RegexMatches(
UuidRegexp,
"value must be a valid UUID or SAP subaccount id ([a-z]########)",
)
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

The error message/format hint doesn’t match the actual regex: ([a-z]########) suggests 1 letter + 8 digits, but the validator accepts 1 lowercase letter + 8 hex chars ([0-9a-fA-F]{8}). Also consider consistent capitalization/grammar (e.g., “SAP subaccount ID” and “an SAP subaccount ID”). Update the message (and/or comment) so users get an accurate validation hint.

Copilot uses AI. Check for mistakes.
@sp1goyal
Copy link
Contributor

sp1goyal commented Feb 4, 2026

Merging the PR, changes requested by copilot will be part of another PR. #232

Copy link
Contributor

@sp1goyal sp1goyal left a comment

Choose a reason for hiding this comment

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

LGTM

@sp1goyal sp1goyal merged commit ede3972 into SAP:main Feb 4, 2026
17 of 18 checks passed
@lechnerc77
Copy link
Member

@davirezendegb Thanks for your contribution. The change will be part of the next release of this provider

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants