Skip to content

Workaround for pgv regex rewrite issue#6714

Merged
jrhee17 merged 1 commit intoline:mainfrom
jrhee17:bugfix/pgv-regex
Apr 9, 2026
Merged

Workaround for pgv regex rewrite issue#6714
jrhee17 merged 1 commit intoline:mainfrom
jrhee17:bugfix/pgv-regex

Conversation

@jrhee17
Copy link
Copy Markdown
Contributor

@jrhee17 jrhee17 commented Apr 8, 2026

Motivation:

Recently, two regex patterns have been added upstream:

https://github.com/envoyproxy/envoy/blob/0baaeb4a832cd5683b221cea98b05ed139b3e332/api/envoy/extensions/filters/http/oauth2/v3/oauth.proto#L148-L149
https://github.com/envoyproxy/envoy/blob/0baaeb4a832cd5683b221cea98b05ed139b3e332/api/envoy/extensions/filters/http/oauth2/v3/oauth.proto#L49

Unfortunately, this results in an error due to invalid java conversion:

/Users/user/Projects/armeria/xds-api/build/generated/sources/proto/main/javapgv/io/envoyproxy/envoy/extensions/filters/http/oauth2/v3/CookieConfigValidator.java:20: error: illegal start of expression
                com.google.re2j.Pattern PATH__PATTERN = com.google.re2j.Pattern.compile("^$|^/[^\\x00-\\x1f\\x7f \\",;<>\\\\]*$");

Where the conversion logic can be found here:
https://github.com/bufbuild/protoc-gen-validate/blob/92b9a7df69ca9f71bfc492f7a90adf4d36eab569/templates/java/register.go#L442

The core issue is regex patterns are rewritten to \\\xHH, \\" both of which are invalid.
As a workaround, I propose that invalid regex patterns are manually rewritten after pgv generation

Modifications:

  • Added a step to rewrite invalid regex after pgv generation in :xds-api

Result:

  • xDS protobuf files can be updated again

@jrhee17 jrhee17 added this to the 1.39.0 milestone Apr 8, 2026
@jrhee17 jrhee17 added the defect label Apr 8, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 37ee73ee-5636-45f8-b8f1-1b23fc903dbf

📥 Commits

Reviewing files that changed from the base of the PR and between 525e983 and 00d263b.

📒 Files selected for processing (1)
  • xds-api/build.gradle

📝 Walkthrough

Walkthrough

A post-processing step is added to the Gradle generateProto task that automatically corrects specific escaping issues in generated Java files from proto/Javapgv sources by applying targeted string replacements and writing back only when modifications occur.

Changes

Cohort / File(s) Summary
Build Configuration
xds-api/build.gradle
Added a doLast action to the generateProto task that scans and post-processes generated Java files to fix escaping issues (\\\xHH\\xHH and \\" sequences).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • ikhoon
  • trustin
  • minwoox

Poem

🐰 The proto files dance and compile with glee,
But escapes run wild in the javapgv spree!
A task came along, with replacements so neat,
Fixed backslashes bright, made the code complete.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary issue being addressed: a workaround for an invalid regex pattern generation problem with protoc-gen-validate (pgv) in the xds-api module.
Description check ✅ Passed The description is well-related to the changeset, providing clear motivation (upstream regex patterns causing invalid Java compilation), the root cause, and explanation of the implemented workaround.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

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

👍👍

Copy link
Copy Markdown
Contributor

@minwoox minwoox left a comment

Choose a reason for hiding this comment

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

👍 👍

@jrhee17 jrhee17 added cleanup and removed defect labels Apr 9, 2026
@jrhee17 jrhee17 merged commit bfe90c8 into line:main Apr 9, 2026
15 of 17 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (8150425) to head (00d263b).
⚠️ Report is 411 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #6714       +/-   ##
============================================
- Coverage     74.46%       0   -74.47%     
============================================
  Files          1963       0     -1963     
  Lines         82437       0    -82437     
  Branches      10764       0    -10764     
============================================
- Hits          61385       0    -61385     
+ Misses        15918       0    -15918     
+ Partials       5134       0     -5134     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants