Skip to content

Conversation

@theparthgupta
Copy link
Contributor

Overview

Implements naming validation for CocoIndex flow identifiers as requested in #779.

Changes

  • New validation module with comprehensive naming rules
  • Integration with flow definition decorator
  • Public API exports for external validation
  • Full test coverage (11 test cases)

Validation Rules

  • Flow/field/target names: [a-zA-Z_][a-zA-Z0-9_]*
  • Maximum 64 characters
  • No double-underscore prefixes

Testing

All existing tests pass. No breaking changes.

Fixes #779

- Implement validation module for flow names, field names, and targets
- Enforce 64-char limit and alphanumeric+underscore restrictions
- Prevent double-underscore prefixes (reserved for internal use)
- Add comprehensive test coverage with 11 test cases
- Maintain backward compatibility

Fixes cocoindex-io#779
- Remove validation functions from public API (internal use only)
- Simplify exception handling - let NamingError be raised directly
- Pre-compile regex patterns for performance optimization
- Add field name validation in DataScope.__setitem__
- Add target name validation in DataCollector.export
@theparthgupta
Copy link
Contributor Author

please review if the changes are correct now or any other thing is needed to be changed

def __init__(
self, name: str, full_name: str, engine_flow_creator: Callable[[], _engine.Flow]
):
validate_full_flow_name(full_name)
Copy link
Member

Choose a reason for hiding this comment

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

Probably we may move the check of validate_flow_name(name) to here too, so similar checks is triggered in the location, which makes code easier to maintain.

@georgeh0 georgeh0 merged commit 9086d9b into cocoindex-io:main Jul 24, 2025
6 checks passed
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.

[FEATURE] Enforce restrictions for flow names, field names, target names, app namespace names

3 participants