← Back to Pull requests

SolrJ: preserve proxy prefixes in v2 request URLs #5373

Open
epugh opened this pull request with 48 lines diff across 3 files
View on GitHub
epugh epugh commented on Nov 21, 2026 12:06 UTC
Author

V2 SolrJ requests sent through a path-prefixed proxy can rewrite the wrong part of the URL. For example, /solr-tenant/solr becomes /api-tenant/solr rather than /solr-tenant/api.

Replace the final complete /solr path segment while preserving the proxy prefix and any following path. Preserve existing /api roots. The fix applies to the shared URL builder used by the Jetty and JDK HTTP clients.

Regression coverage uses a generated snapshot-list request and checks ordinary roots, proxy prefixes containing /solr, and existing v2 roots. This is separate from the snapshot API and CLI migration in #5353.

Validation: all 5 ClientUtilsTest tests, ./gradlew tidy, and ./gradlew check -x test passed.

Developed with assistance from OpenAI Codex.

Diff: 48 lines (+43 / -5) across 3 files Reviewer: nick-boss-tech Review duration: 10063m
All Vouch review confidence checks passed
Residual risk 0.06 = Change Risk (0.34) × (1 − Review Confidence (0.81)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.34 · 48 lines diff across 3 files
0.34
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.72 · 3 substantive comment(s)
0.72
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
81%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.233
Ai Authored ai_authored
0.050
Real PR Conversation Timeline
6 items
github-actions[bot] github-actions[bot] commented on Nov 21, 2026 12:07 UTC
Bot

Automated PR readiness judgements (LLM-generated; may be wrong; not updated on later pushes).

  • ⚠️ Jira issue in title — missing: This fixes a bug in SolrJ where V2 request URLs were incorrectly rewritten when using path-prefixed proxies, which is a user-visible issue warranting a Jira ticket and changelog entry.​

  • ⚠️ Changelog — missing (suggest type: fixed): The change corrects buggy URL construction logic in ClientUtils.​java that caused incorrect path replacement for proxied requests, fixing a user-visible symptom.​

  • ✅ Reference Guide update: not needed <!-- This is an internal bug fix to the SolrJ client library&#39;s URL building logic and does not introduce new configuration&#44; parameters&#44; or documented behaviors that require Reference Guide updates&#46;​ -->

  • ✅ Upgrade notes: not needed <!-- The change is a bug fix that corrects behavior to match expectations and does not remove or rename any APIs or change defaults in a backwards&#45;incompatible way&#46;​ -->

  • ✅ Tests: included <!-- The PR modifies non&#45;trivial production logic in ClientUtils&#46;​java for URL path manipulation&#44; which requires new or changed tests to verify the correct handling of proxy prefixes and existing API roots&#46;​ -->
  • <!-- Assessed commit 303f0b0b8fdcd697f76e8d15357e3664d5127e67 -->

    nick-boss-tech nick-boss-tech approved these changes on Nov 22, 2026 03:11 UTC
    Approved Reviewer

    Approved these changes.

    isaric isaric commented on code on Nov 26, 2026 14:19 UTC
    Code Review
    solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java:1
    @@ -79,13 +79,19 @@ private static String addNormalV2ApiRoot(String basePath) throws MalformedURLExc
       }
     
       private static String buildReplacementV2Path(String existingPath) {

    Nit: a one-line javadoc stating the rule would help, since the test is now the only place that documents it: replace the last complete /solr segment, keep an existing /api root, otherwise append /api.

    isaric isaric commented on code on Nov 26, 2026 14:19 UTC
    Code Review
    solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java:1
    @@ -79,13 +79,19 @@ private static String addNormalV2ApiRoot(String basePath) throws MalformedURLExc
       }
     
       private static String buildReplacementV2Path(String existingPath) {
    -    if (existingPath.contains("/solr")) {
    -      return existingPath.replaceFirst("/solr", "/api");
    -    } else if (existingPath.endsWith("/api")) {
    +    if (existingPath.endsWith("/api")) {

    Nit, pre-existing: a base path with a trailing slash (/solr/, /tenant/solr/) yields /api//collections/.... The Jetty builder strips the slash, but HttpJdkSolrClient passes an override base URL straight through, so trimming a trailing / here would close it cheaply. Fine as a follow-up.

    isaric isaric approved these changes on Nov 26, 2026 14:19 UTC
    Approved Reviewer

    LGTM. Verified locally on the PR head: the five ClientUtilsTest cases pass, and I probed ten more bases the table doesn't cover (/solrcloud, /mysolr, /SOLR, /solr/solr, /solr/api, /api/solr, trailing-slash variants); every result is either correct or identical to what main produced before, so no regressions. This is the only /solr -> /api rewrite in SolrJ, so the fix is complete for the client path.

    The two red core-test jobs fail in TestDocTermOrds.testRandom and TestLockTree.testLocks, which a SolrJ URL change can't reach; no open JIRA for either, so they look like fresh flakiness rather than this PR.

    Two optional nits inline.

    Assignees
    epugh epugh
    Labels
    risk: low confidence: 81.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 34.2% (LOW) · Higher = larger blast radius
    34.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 81.5% · Lower = rushed or shallow review
    81.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 6.3% · Safe to merge
    6.3%
    Repository