Skip to content

[ISSUE #10683] Validate proxy metric collector address - #10684

Open
Aias00 wants to merge 2 commits into
apache:developfrom
Aias00:fix/proxy-metric-collector-address-validation
Open

[ISSUE #10683] Validate proxy metric collector address#10684
Aias00 wants to merge 2 commits into
apache:developfrom
Aias00:fix/proxy-metric-collector-address-validation

Conversation

@Aias00

@Aias00 Aias00 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Fixes #10683

Brief Description

GrpcClientSettingsManager.mergeMetric previously parsed metricCollectorAddress with split(":") and directly read split[1]. When metricCollectorMode=on but the configured address was empty, missing a port, or using a non-numeric port, the gRPC client settings path could throw a runtime exception while constructing the client metric endpoint.

This PR validates the configured collector address before building the endpoint. Invalid addresses now disable the client metric collector for the settings response and log a warning, while valid host:port values keep the existing behavior.

How Did You Test This Change?

mvn -pl proxy -Dtest=GrpcClientSettingsManagerTest -DfailIfNoTests=false test

Result: BUILD SUCCESS, Tests run: 9, Failures: 0, Errors: 0, Skipped: 0.

Copilot AI review requested due to automatic review settings July 29, 2026 07:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review by github-manager-bot

Summary

Validates metricCollectorAddress in GrpcClientSettingsManager.mergeMetric before parsing, preventing runtime exceptions when the address is empty, malformed, or has a non-numeric port.

Findings

  • [Info] GrpcClientSettingsManager.java:143-158 — The new parseMetricCollectorAddress method handles all edge cases: blank input, missing colon separator, empty host/port, and non-numeric port. Returns null for invalid input, allowing the caller to gracefully disable the metric collector.
  • [Info] GrpcClientSettingsManager.java:121-126 — The caller correctly handles null by logging a warning and setting metricBuilder.setOn(false), which prevents the client from attempting to connect to an invalid endpoint.
  • [Info] Uses StringUtils.isBlank() from commons-lang3, consistent with existing dependencies in the project.
  • [Info] GrpcClientSettingsManagerTest.java — Tests cover valid address and multiple invalid scenarios (blank, missing port, non-numeric port). Good coverage.

Suggestions

  • [Info] Consider making parseMetricCollectorAddress private instead of protected if external subclassing is not intended. Minor style point.
  • [Info] The split(":") approach assumes IPv4 addresses. If IPv6 support is needed in the future, consider using a more robust parsing approach (e.g., InetSocketAddress.createUnresolved()). Not blocking for this PR.

Overall: Solid defensive improvement. Prevents a potential runtime exception in the gRPC client settings path when the metric collector is enabled but the address is misconfigured.


Automated review by github-manager-bot

@codecov-commenter

codecov-commenter commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.26%. Comparing base (00e45b8) to head (621a345).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10684      +/-   ##
=============================================
- Coverage      48.31%   48.26%   -0.06%     
+ Complexity     13511    13498      -13     
=============================================
  Files           1380     1380              
  Lines         101091   101100       +9     
  Branches       13101    13103       +2     
=============================================
- Hits           48844    48795      -49     
- Misses         46285    46320      +35     
- Partials        5962     5985      +23     

☔ View full report in Codecov by Harness.
📢 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.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review by github-manager-bot (Re-review)

PR #10684: [ISSUE #10683] Validate proxy metric collector address
Re-review scope: New commit 621a345 — "Cover blank metric collector port"

Changes Since Last Review

  • Added test case for blank metric collector port value — covers the edge case where the address has a colon but the port portion is empty or whitespace

Assessment

Tests — Good additional coverage for the blank-port edge case in parseMetricCollectorAddress.

Overall: LGTM — Test coverage is now comprehensive for all validation branches.


Automated re-review by github-manager-bot

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.

[Bug] Proxy gRPC client settings should tolerate malformed metric collector address

4 participants