Skip to content

fix: trim leading or trailing whitespace on DB and RP names#27553

Open
davidby-influx wants to merge 2 commits into
master-1.xfrom
DSB/trim_name
Open

fix: trim leading or trailing whitespace on DB and RP names#27553
davidby-influx wants to merge 2 commits into
master-1.xfrom
DSB/trim_name

Conversation

@davidby-influx

Copy link
Copy Markdown
Contributor

Trim leading and trailing whitespace on DB and RP names before comparison or creation. " foo " will become "foo" Upgrading to this functionality should only be done to instances without such existing DB & RP names

Closes https://github.com/influxdata/feature-requests/issues/219

Trim leading and trailing whitespace on DB and RP names
before comparison or creation.  " foo  " will become "foo"
Upgrading to this functionality should only be done to
instances withtou such existing DB & RP names

Copilot AI left a comment

Copy link
Copy Markdown

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 standardizes database (DB) and retention policy (RP) naming by trimming leading/trailing whitespace before validating, comparing for existence, and persisting names in the meta layer. It updates the meta client to enforce the normalized (trimmed) names as the canonical representation and removes redundant pre-validation in higher layers that now rely on the meta client as the chokepoint.

Changes:

  • Change meta.ValidName to return (trimmedName, ok) and trim surrounding whitespace as part of validation.
  • Validate/normalize DB and RP names in meta.Client create paths (CreateDatabase, CreateDatabaseWithRetentionPolicy, CreateRetentionPolicy).
  • Remove redundant name validation from the HTTP handler and statement executor; add focused tests for trimming and invalid-name rejection.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
services/meta/validname_test.go Adds unit tests for trimming behavior and invalid-name cases for ValidName.
services/meta/data.go Updates ValidName to trim whitespace and return the trimmed name alongside validity.
services/meta/client.go Enforces trimmed/validated DB & RP names at meta-client creation chokepoints.
services/meta/client_validname_test.go Adds meta-client tests for rejection, trimming semantics, and concurrency stress.
services/httpd/handler.go Removes redundant RP validation and relies on meta-client validation.
services/httpd/handler_test.go Updates expected error messages and adjusts mocks to reflect meta-client validation.
coordinator/statement_executor.go Removes redundant validation and delegates to meta-client create methods.

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

Comment thread services/meta/client_validname_test.go
Comment thread services/meta/client_validname_test.go
Comment thread services/meta/client_validname_test.go
Comment thread services/httpd/handler_test.go Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants