Skip to content

fix(util): keep hostnames starting with v1 in remove_url_endpoints - #2799

Open
udsy19 wants to merge 1 commit into
NVIDIA:mainfrom
udsy19:fix/remove-url-endpoints-host-v1
Open

udsy19 wants to merge 1 commit into
NVIDIA:mainfrom
udsy19:fix/remove-url-endpoints-host-v1

Conversation

@udsy19

@udsy19 udsy19 commented Oct 21, 2026

Copy link
Copy Markdown

Bug

remove_url_endpoints (nemo_retriever/.../common/api/util/string_processing/__init__.py) did:

if "/v1" in url:
    url = url.split("/v1")[0]

"/v1" matches anywhere in the string, including the // + host. So a NIM endpoint whose hostname starts with v1 is truncated to http:/:

remove_url_endpoints("http://v1-nim:8000/v1/chat/completions")  # -> "http:/"
remove_url_endpoints("http://v1-nim:8000")                      # -> "http:/"

It's called by _query_metadata and the NIM readiness check in models/nim/primitives/model_interface/helpers.py, so any NIM whose host starts with v1 (e.g. v1-nim) gets a broken URL and looks permanently not-ready.

Fix

Match /v1 only as a whole path segment (never inside the authority):

_V1_PATH_SEGMENT = re.compile(r"(?<!/)/v1(?=[/?#]|$)")
...
match = _V1_PATH_SEGMENT.search(url)
if match:
    url = url[: match.start()]
  • http://v1-nim:8000/v1/chat → http://v1-nim:8000
  • http://v1-nim:8000 → unchanged
  • http://nim:8000/v1/chat → http://nim:8000 (unchanged behavior)

This also stops the previous over-match on /v1beta//v10, which are no longer treated as the /v1 endpoint.

Tests

Adds parametrized cases to nemo_retriever/tests/test_common_string_processing.py. Verified fail-on-revert: reverting the source makes the v1-hostname cases collapse to http:/; with the fix all 6 cases pass.

remove_url_endpoints split on the first '/v1' anywhere in the URL, so
a host such as http://v1-nim:8000 matched the '//v1' in the authority
and was truncated to 'http:/'. Match '/v1' only as a path segment.

Signed-off-by: Udaya Tejas <udayatejas2004@gmail.com>
@udsy19
udsy19 requested review from a team as code owners October 21, 2026 14:51
@udsy19
udsy19 requested a review from jioffe502 October 21, 2026 14:51
@copy-pr-bot

copy-pr-bot Bot commented Oct 21, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@greptile-apps

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects URL handling for NIM readiness and metadata requests.

The PR appears safe to merge, with a non-blocking request to test longer version prefixes.

Findings

  1. P2 Longer version paths lack tests ▶
Fix with agent prompt
### Issue 1
nemo_retriever/tests/test_common_string_processing.py:14
The new cases cover hostname preservation, but none checks that `/v1beta` and `/v10` paths stay untouched. Add those cases to `test_remove_url_endpoints`. Without them, removing the regex’s right-hand boundary could restore the over-match while all six tests still pass.

```suggestion
        ("http://deplot:8000/v1", "http://deplot:8000"),
        ("http://deplot:8000/v1beta/chat/completions", "http://deplot:8000/v1beta/chat/completions"),
        ("http://deplot:8000/v10/chat/completions", "http://deplot:8000/v10/chat/completions"),
```

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Updates remove_url_endpoints to preserve hostnames starting with v1.

  • NIM URL cleanup keeps v1 hostnames intact.

The untouched /v1beta and /v10 behavior is intentional, as stated in the PR description supplied by udsy19.

Reviews (1) · Last reviewed commit: "fix(util): keep hostnames starting with ..." · Reviewed by Greptile

("url", "expected"),
[
("http://deplot:8000/v1/chat/completions", "http://deplot:8000"),
("http://deplot:8000/v1", "http://deplot:8000"),

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.

P2 Longer version paths lack tests

The new cases cover hostname preservation, but none checks that /v1beta and /v10 paths stay untouched. Add those cases to test_remove_url_endpoints. Without them, removing the regex’s right-hand boundary could restore the over-match while all six tests still pass.

Suggested change
("http://deplot:8000/v1", "http://deplot:8000"),
("http://deplot:8000/v1", "http://deplot:8000"),
("http://deplot:8000/v1beta/chat/completions", "http://deplot:8000/v1beta/chat/completions"),
("http://deplot:8000/v10/chat/completions", "http://deplot:8000/v10/chat/completions"),
Prompt To Fix With AI
This is a comment left during a code review.
Path: nemo_retriever/tests/test_common_string_processing.py
Line: 14

Comment:
**Longer version paths lack tests**

The new cases cover hostname preservation, but none checks that `/v1beta` and `/v10` paths stay untouched. Add those cases to `test_remove_url_endpoints`. Without them, removing the regex’s right-hand boundary could restore the over-match while all six tests still pass.

```suggestion
        ("http://deplot:8000/v1", "http://deplot:8000"),
        ("http://deplot:8000/v1beta/chat/completions", "http://deplot:8000/v1beta/chat/completions"),
        ("http://deplot:8000/v10/chat/completions", "http://deplot:8000/v10/chat/completions"),
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

This branch has not been deployed

No deployments
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.

1 participant