Skip to content

Conversation

@tobio
Copy link
Member

@tobio tobio commented Dec 16, 2025

Related to #1553

Without this we get a fairly unhelpful 400 API response, it's a nicer UX providing immediate, and specific feedback.

@tobio tobio requested a review from dimuon December 16, 2025 03:31
@tobio tobio self-assigned this Dec 16, 2025
Copilot AI review requested due to automatic review settings December 16, 2025 03:31
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

This PR adds validation to ensure space IDs conform to the Kibana API requirements before attempting to create or update spaces. The validation provides immediate, specific feedback to users rather than letting them encounter an unhelpful 400 error from the API.

Key Changes:

  • Added a ValidateFunc to the space ID field that enforces lowercase letters, numbers, hyphens, and underscores only

Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(regexp.MustCompile("[a-z0-9_-]+"), "must only contain lowercase letters, numbers, hyphens, and underscores"),
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The regex is compiled on every validation call. Consider using regexp.MustCompile outside the schema definition or using a pre-compiled pattern to avoid repeated compilation overhead during resource operations.

Copilot uses AI. Check for mistakes.
@tobio tobio merged commit 946b987 into main Dec 16, 2025
54 checks passed
@tobio tobio deleted the space-id-validation branch December 16, 2025 10:55
Copy link
Contributor

@dimuon dimuon left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants