Skip to content

feat(gax): implement REST URI percent-encoding and dot segment validation - #9484

Merged
cy-yun merged 5 commits into
mainfrom
feature/rest-uri-percent-encoding-validation
Aug 13, 2026
Merged

feat(gax): implement REST URI percent-encoding and dot segment validation#9484
cy-yun merged 5 commits into
mainfrom
feature/rest-uri-percent-encoding-validation

Conversation

@cy-yun

@cy-yun cy-yun commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description

This PR implements AIP-136 requirements for custom HTTP bindings, specifically for REST URI percent-encoding and dot segment validation, while preserving backward compatibility for GAPIC client resource names.

Key Changes

  1. REST URI Percent-Encoding

    • Values bound to URI variables (* and **) are now correctly URL-encoded.
    • For double wildcard segments (**), forward slashes (/) are preserved, while the individual components between the slashes are properly percent-encoded.
    • This ensures that reserved characters in URIs are safely encoded.
  2. Dot Segment Validation

    • HTTP binding values mapped to variables must not contain segments that are exactly . or ...
    • If a variable bound to * or ** contains an exact . or .. segment, the template renderer will now throw an InvalidArgumentException.
  3. Backward Compatibility & Resource Name Fixes

    • The original implementation of AIP-136 inadvertently applied URL encoding to resource names used internally and in gRPC clients (e.g., encoding (default) to %28default%29), leading to widespread unit test failures across other GAPIC clients like Firestore and Datastore.
    • This PR resolves those issues by introducing an optional $urlEncode parameter to render() in RelativeResourceTemplate, AbsoluteResourceTemplate, and PathTemplate, which defaults to false.
    • RequestBuilder::tryRenderPathTemplate() has been updated to explicitly pass $urlEncode = true, ensuring that the percent-encoding behavior is safely scoped only to the final REST URI request path generation.

Related Issues

@cy-yun
cy-yun marked this pull request as ready for review August 12, 2026 18:41
@cy-yun
cy-yun requested a review from a team as a code owner August 12, 2026 18:41
Comment thread Gax/src/ResourceTemplate/RelativeResourceTemplate.php Outdated
@cy-yun
cy-yun merged commit f3a7276 into main Aug 13, 2026
40 checks passed
@cy-yun
cy-yun deleted the feature/rest-uri-percent-encoding-validation branch August 13, 2026 20:32
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.

3 participants