Skip to content

fix: validate tag and field names when creating tables#26641

Merged
hiltontj merged 4 commits intomainfrom
fix/validate-table-creation-keys
Jul 30, 2025
Merged

fix: validate tag and field names when creating tables#26641
hiltontj merged 4 commits intomainfrom
fix/validate-table-creation-keys

Conversation

@hiltontj
Copy link
Copy Markdown
Contributor

@hiltontj hiltontj commented Jul 29, 2025

Summary

Adds validation to reject empty tag and field names, or those containing control characters when creating tables via the catalog API, ensuring compatibility with the line protocol parser.

Changes

Validation logic

Added validate_key() function in influxdb3_catalog/src/catalog/update.rs that rejects:

  • Empty strings
  • Control characters (ASCII 0x00-0x1F and 0x7F)

Test coverage:

  • Unit tests with rstest for various invalid cases (empty strings, newlines, tabs, etc.)
  • Unit tests confirming valid names including those requiring line protocol escaping (spaces, commas, equals)
  • Integration test demonstrating end-to-end table creation and line protocol writes with special characters

Notes

  • Not a breaking change - tables with control characters were already unusable via line protocol
  • Special characters (spaces, commas, equals) remain supported with proper escaping
  • Unicode characters continue to work as expected

Fixes #26486

Add validation to ensure tag and field names follow line protocol rules
when creating tables via the catalog API. This prevents creating tables
with invalid column names that would be rejected by the line protocol
parser.

The validation checks that tag and field names:
- Are not empty
- Do not contain spaces
- Do not contain commas
- Do not contain equals signs

Closes #26486
@hiltontj hiltontj marked this pull request as draft July 29, 2025 02:11
Add unit tests using rstest to verify that the create_table method
properly validates tag and field names according to line protocol rules.

The tests cover:
- Invalid cases: empty names
- Valid cases: simple names, underscores, numbers, and mixed alphanumeric
- Valid cases with escapes
- Verification that tables are created correctly with valid names

This ensures the validation added in the previous commit works as expected.
@hiltontj hiltontj force-pushed the fix/validate-table-creation-keys branch 3 times, most recently from 660e397 to e24b4a6 Compare July 30, 2025 01:30
@hiltontj hiltontj force-pushed the fix/validate-table-creation-keys branch 2 times, most recently from a8ad3c0 to e83a857 Compare July 30, 2025 02:26
@hiltontj hiltontj force-pushed the fix/validate-table-creation-keys branch from e83a857 to cac9f8c Compare July 30, 2025 12:20
@hiltontj hiltontj marked this pull request as ready for review July 30, 2025 15:45
@hiltontj hiltontj merged commit 5395b19 into main Jul 30, 2025
13 checks passed
@hiltontj hiltontj deleted the fix/validate-table-creation-keys branch July 30, 2025 16:33
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.

Validate tags and fields when creating tables using the same rules as the line protocol parser

2 participants