Skip to content

feat: validate topicNameTemplate with context variable resolution#71

Open
yannrouillard wants to merge 6 commits into
mainfrom
feat/topic-name-template-compliance
Open

feat: validate topicNameTemplate with context variable resolution#71
yannrouillard wants to merge 6 commits into
mainfrom
feat/topic-name-template-compliance

Conversation

@yannrouillard
Copy link
Copy Markdown
Contributor

Summary

  • Extends validate_topic_name_compliance to handle topicNameTemplate fields by detecting the field type via the JSON Schema path tracker
  • Adds _resolve_topic_name_template() which replaces known context variables (serviceName, instanceName, serviceInstanceName, env) with their actual values, then validates the resolved topic name against the same rules as static topicName
  • This enables using {{ $.context.serviceInstanceName }}-store-changelog while still verifying the serviceName-instanceName prefix is correct

Companion PR: Kpler/platform-managed-chart — relaxes the topicNameTemplate regex for internal topics.

Test plan

  • End-to-end test with local schema: 8/8 scenarios pass (valid templates, wrong prefix rejected, missing instance rejected)
  • Integration tests (require VPN + published schema): 2 new test cases added with fixtures

tobias-schnabel and others added 6 commits March 28, 2026 10:35
Kafka Streams changelog and repartition topics use
{applicationId}-{name}-(changelog|repartition) naming which doesn't
follow the serviceName.dataIdentifier convention. Allow these through.
…me prefix

Prevent copy-paste mistakes where an internal topic is reused across
service instances by checking that changelog/repartition topics start
with {serviceName}-{instanceName}-, matching the Kafka Streams applicationId
convention.
Replace PR version 0.1.157-pr195 with stable 0.1.224 (base) and 0.1.225
(dev override), which are the latest stable releases and include the
maxLocalTopicBytesCompliance custom validator support.

This also properly demonstrates the env-specific chart loading feature
with two distinct stable versions.
- Version suffix: (-[0-9]+)? → (-v[0-9]+)? to require the v prefix (e.g. -v1)
- Instance suffix: (\.[a-z0-9]+)? → (\.[a-z0-9-]+)? to allow hyphens (e.g. .mirrored-prod)
…omment

- Delete unused service2 Kafka Streams test data files (leftover from
  before the prefix check was introduced; would have failed if tested)
- Add test + data for internal topic from a foreign service (wrong
  serviceName prefix, not just wrong instance)
- Add tests + data pinning the TOPIC_NAME_REGEXP changes: -vN suffix
  and hyphenated suffix are now accepted
- Clarify TOPIC_NAME_REGEXP comment: format validation is the schema's
  responsibility; the regexp only enforces service name ownership
Extend validate_topic_name_compliance to handle topicNameTemplate fields.
When validating a template, known context variables (serviceName,
instanceName, serviceInstanceName, env) are resolved to their actual
values before checking the topic name structure. This enables using
$.context.serviceInstanceName in changelog/repartition topics while
still verifying the serviceName-instanceName prefix is correct.
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.

2 participants