Allow dots and forbid slashes in new xDS resource IDs - #1334
Conversation
Motivation: We have decided to allow dots in a xDS group name and resource ID. At the same time, slashes are disallowed in a resource ID. Existing resources whose IDs contain slashes (created before this change) must continue to be updatable and deletable, so backward compatibility must be preserved for update/delete operations. Modifications: - Allow dots and forbid slashes in an xDS group name and resource ID. Result: - Dots are now allowed in xDS group names and resource IDs. - Slashes are rejected when creating new resources.
📝 WalkthroughWalkthroughThe change updates XDS resource ID validation to allow dots and reject slashes for new resources. Legacy slash-containing names remain parseable for update and delete operations. Webapp forms and XDS tests now cover the revised rules. ChangesXDS resource ID validation
Webapp validation
Backend validation tests
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@webapp/src/dogma/features/xds/K8sAggregatorEditor.tsx`:
- Around line 454-463: The validation message alongside the registered
aggregatorId field does not reflect the corrected character-class range. Update
the text in the FormErrorMessage for aggregatorId so the hyphen appears at the
end of the character class, matching AGGREGATOR_ID_PATTERN while preserving the
stated slash restriction.
In `@webapp/src/dogma/features/xds/NewGroup.tsx`:
- Around line 92-93: Update the Group ID validation message near the NewGroup
form to use the corrected regular-expression character-class syntax, ensuring
the displayed pattern accurately matches the validator while preserving the
existing allowed-character description.
In `@webapp/src/dogma/features/xds/ResourceEditor.tsx`:
- Around line 98-107: Update the Invalid ID notification message in the
idIsInvalid branch to describe the safely formulated character class, placing
the hyphen as a literal rather than implying a range. Keep the stated
lowercase-start, lowercase/digit/underscore/dot/hyphen body, lowercase-or-digit
ending, and slash prohibition consistent with validation.
- Around line 134-139: Update the validation text in the ResourceEditor form’s
FormErrorMessage to accurately describe the safely formulated ID regular
expression, correcting the character-class range while preserving the existing
allowed-character and slash restriction guidance.
In
`@xds/src/main/java/com/linecorp/centraldogma/xds/internal/XdsResourceManager.java`:
- Around line 74-81: Move the hyphen to the end of both character classes in
XdsResourceManager’s RESOURCE_ID_PATTERN_STRING and
LEGACY_RESOURCE_ID_PATTERN_STRING. Apply the same corrected resource-ID regex in
K8sAggregatorEditor, NewGroup, and ResourceEditor, and update every associated
validation, notification, and form error message in the specified ranges to
display [a-z0-9_.-].
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f4e5375e-0118-4ca5-891a-952f6f582194
📒 Files selected for processing (18)
webapp/src/dogma/features/xds/K8sAggregatorEditor.tsxwebapp/src/dogma/features/xds/NewGroup.tsxwebapp/src/dogma/features/xds/ResourceEditor.tsxwebapp/tests/dogma/features/xds/K8sAggregatorEditor.test.tsxxds/src/main/java/com/linecorp/centraldogma/xds/cluster/v1/XdsClusterService.javaxds/src/main/java/com/linecorp/centraldogma/xds/endpoint/v1/XdsEndpointService.javaxds/src/main/java/com/linecorp/centraldogma/xds/internal/XdsResourceManager.javaxds/src/main/java/com/linecorp/centraldogma/xds/k8s/v1/XdsKubernetesService.javaxds/src/main/java/com/linecorp/centraldogma/xds/listener/v1/XdsListenerService.javaxds/src/main/java/com/linecorp/centraldogma/xds/route/v1/XdsRouteService.javaxds/src/test/java/com/linecorp/centraldogma/xds/cluster/v1/XdsClusterServiceTest.javaxds/src/test/java/com/linecorp/centraldogma/xds/endpoint/v1/XdsEndpointServiceTest.javaxds/src/test/java/com/linecorp/centraldogma/xds/endpoint/v1/XdsRegisterEndpointTest.javaxds/src/test/java/com/linecorp/centraldogma/xds/group/v1/XdsGroupServiceTest.javaxds/src/test/java/com/linecorp/centraldogma/xds/k8s/v1/AggregatingMultipleKubernetesTest.javaxds/src/test/java/com/linecorp/centraldogma/xds/k8s/v1/XdsKubernetesServiceTest.javaxds/src/test/java/com/linecorp/centraldogma/xds/listener/v1/XdsListenerServiceTest.javaxds/src/test/java/com/linecorp/centraldogma/xds/route/v1/XdsRouteServiceTest.java
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
xds/src/test/java/com/linecorp/centraldogma/xds/k8s/v1/XdsKubernetesServiceTest.java (1)
325-325: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winRetain regression coverage for legacy slash-containing IDs.
These update and delete tests now use only dotted IDs, so they no longer verify the required backward compatibility for existing resources such as
foo-k8s-cluster/2andfoo-k8s-cluster/3. Add dedicated cases that seed or otherwise load a legacy resource first, then PATCH/DELETE it using the slash-containing resource name; reverting these POST-based setups directly would incorrectly exercise the new-resource validation instead.Also applies to: 366-366
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@xds/src/test/java/com/linecorp/centraldogma/xds/k8s/v1/XdsKubernetesServiceTest.java` at line 325, Restore dedicated regression cases in the update and delete tests around the existing aggregatorId usages, first seeding or loading legacy resources named foo-k8s-cluster/2 and foo-k8s-cluster/3, then PATCHing or DELETEing those slash-containing names. Do not merely revert the POST setup, since creation must continue testing new-resource validation while update and delete verify backward compatibility.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In
`@xds/src/test/java/com/linecorp/centraldogma/xds/k8s/v1/XdsKubernetesServiceTest.java`:
- Line 325: Restore dedicated regression cases in the update and delete tests
around the existing aggregatorId usages, first seeding or loading legacy
resources named foo-k8s-cluster/2 and foo-k8s-cluster/3, then PATCHing or
DELETEing those slash-containing names. Do not merely revert the POST setup,
since creation must continue testing new-resource validation while update and
delete verify backward compatibility.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3dfc0d1d-f354-48d7-a2a1-68aa94733249
📒 Files selected for processing (9)
webapp/src/dogma/features/xds/K8sAggregatorEditor.tsxwebapp/src/dogma/features/xds/NewGroup.tsxwebapp/src/dogma/features/xds/ResourceEditor.tsxxds/src/main/java/com/linecorp/centraldogma/xds/internal/XdsResourceManager.javaxds/src/main/java/com/linecorp/centraldogma/xds/k8s/v1/XdsKubernetesService.javaxds/src/test/java/com/linecorp/centraldogma/xds/endpoint/v1/XdsEndpointServiceTest.javaxds/src/test/java/com/linecorp/centraldogma/xds/endpoint/v1/XdsRegisterEndpointTest.javaxds/src/test/java/com/linecorp/centraldogma/xds/k8s/v1/AggregatingMultipleKubernetesTest.javaxds/src/test/java/com/linecorp/centraldogma/xds/k8s/v1/XdsKubernetesServiceTest.java
🚧 Files skipped from review as they are similar to previous changes (7)
- webapp/src/dogma/features/xds/NewGroup.tsx
- xds/src/main/java/com/linecorp/centraldogma/xds/k8s/v1/XdsKubernetesService.java
- webapp/src/dogma/features/xds/K8sAggregatorEditor.tsx
- xds/src/test/java/com/linecorp/centraldogma/xds/k8s/v1/AggregatingMultipleKubernetesTest.java
- webapp/src/dogma/features/xds/ResourceEditor.tsx
- xds/src/test/java/com/linecorp/centraldogma/xds/endpoint/v1/XdsRegisterEndpointTest.java
- xds/src/test/java/com/linecorp/centraldogma/xds/endpoint/v1/XdsEndpointServiceTest.java
Motivation:
We have decided to allow dots in a xDS group name and resource ID. At the same time, slashes are disallowed in a resource ID.
Existing resources whose IDs contain slashes (created before this change) must continue to be updatable and deletable, so backward compatibility must be preserved for update/delete operations.
Modifications:
Result: