Validate private endpoint IDs before registering them - #621
Merged
sdairs merged 2 commits intoSep 3, 2026
Merged
Conversation
sdairs
force-pushed
the
fix/611-private-endpoint-id-validation
branch
from
August 28, 2026 14:46
c1633e9 to
9dd3fa5
Compare
sdairs
force-pushed
the
fix/611-private-endpoint-id-validation
branch
from
August 28, 2026 19:42
9dd3fa5 to
5265266
Compare
`cloud service private-endpoint create --endpoint-id` and `cloud service update --add-private-endpoint-id` accepted any string. The API does not check the value either, so a typo registered a dud endpoint org-wide that had to be unpicked from both the service and the organization. Add a clap `value_parser` on both add-flags so a malformed ID fails as a usage error (exit 2) before any request is sent. The provider is unknown at parse time and the three formats are unrelated (AWS `vpce-` VPC endpoint ID, GCP numeric PSC connection ID, Azure private endpoint Resource ID or resourceGuid), so only provider-independent mistakes are rejected: empty values, whitespace, and any value carrying `vpce-` that is not exactly `vpce-` plus 8 or 17 lowercase hex characters (catching truncated, uppercased, ARN- and service-name-pasted IDs). Azure Resource IDs are exempt from the AWS check because such a resource may itself be named `vpce-...`. Removal flags are deliberately unchecked so an already-registered bogus ID stays removable. Ownership/existence is not validated: that is not checkable client-side and remains an upstream API gap. Tests: clap accept/reject cases for both flags plus the remove-flag escape hatch, unit tests for the validator across all three provider formats, and wiremock subprocess tests asserting exit 2 with no request issued for a malformed ID and verbatim forwarding of valid AWS/GCP/Azure IDs. Fixes #611 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The validator accepts both the 8- and 17-character hex forms and the README says so, but the rejection message only named 17. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
sdairs
force-pushed
the
fix/611-private-endpoint-id-validation
branch
from
September 1, 2026 20:36
5265266 to
6113dba
Compare
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.
Fixes #611
What
cloud service private-endpoint create --endpoint-id(andcloud service update --add-private-endpoint-id, the non-deprecated route to the same field) accepted any string. The Cloud API does not validate the value either, so a typo exited 0 and registered a dud endpoint org-wide, which then had to be unpicked from both the service and the organization by hand.Both add-flags now use a clap
value_parser, so a malformed ID fails as a usage error (exit code2) before any request is sent.Why this validation and no more
The provider is not known when the flag is parsed, and the three formats are unrelated:
vpce-+ 8 (legacy) or 17 lowercase hex characters102600141743718403/subscriptions/.../privateEndpoints/<name>) or the legacyresourceGuidOnly provider-independent mistakes are therefore rejected:
id: ""),vpce-that is not exactly a well-formed AWS VPC endpoint ID — which catchesvpce-bogus, truncated IDs, uppercased IDs (AWS never issues those, so they would register a dud), a pasted VPC endpoint ARN, and a pastedcom.amazonaws.vpce.<region>.vpce-svc-...endpoint service name.GCP and Azure IDs have no marker that separates a typo from a valid value, so they pass through verbatim. Azure Resource IDs (values starting with
/) are exempt from the AWS check, because such a resource may itself be namedvpce-....Removal flags (
--remove-private-endpoint-id,cloud org update --remove-private-endpoint) are deliberately not checked: an already-registered bogus ID must stay removable, which is exactly the cleanup path the issue describes.Not fixed: ownership / existence
Whether the endpoint exists and belongs to the caller is not checkable client-side — the CLI has no AWS/GCP/Azure credentials — and the Cloud API accepts any string. That half of the issue is an upstream API gap; the CLI can only reject values that cannot be an endpoint ID in any provider's format.
Tests
--endpoint-idand--add-private-endpoint-idassertingErrorKind::ValueValidation, and the deliberate escape hatch on--remove-private-endpoint-id.tests/cli_request_shape_test.rs: a malformed ID exits2with no request reaching the mock server; a valid AWS ID and both non-AWS formats are forwarded verbatim in the POST body.vpce-1test fixtures updated to well-formed IDs.cargo fmt --all,cargo clippy --workspace --all-targets -- -D warnings, andcargo test -p clickhousectlall clean.README documents the new validation, the per-provider formats, and the unvalidated ownership gap.
🤖 Generated with Claude Code