fix: trim leading or trailing whitespace on DB and RP names#27553
Open
davidby-influx wants to merge 2 commits into
Open
fix: trim leading or trailing whitespace on DB and RP names#27553davidby-influx wants to merge 2 commits into
davidby-influx wants to merge 2 commits into
Conversation
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
There was a problem hiding this comment.
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.ValidNameto return(trimmedName, ok)and trim surrounding whitespace as part of validation. - Validate/normalize DB and RP names in
meta.Clientcreate 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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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