Repository navigation
Feat: optional url v1 - #16774
Feat: optional url v1#16774
Conversation
📝 WalkthroughWalkthroughIntroduces a shared ChangesURL Normalization and Provider Base URL Handling
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant ProviderInit as Provider __init__
participant EnsureV1 as ensure_v1
participant SDKClient as OpenAI/AzureOpenAI/Ollama Client
ProviderInit->>EnsureV1: normalize(base_url)
EnsureV1-->>EnsureV1: check for /v{digit} segment
EnsureV1-->>ProviderInit: normalized base_url
ProviderInit->>SDKClient: construct(base_url=normalized)
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rag/llm/cv_model.py`:
- Around line 314-316: The Azure client setup in cv_model.py is rewriting the
endpoint with ensure_v1(), which breaks AzureOpenAI and AsyncAzureOpenAI request
paths by appending an invalid /v1 segment. Update the initialization in the
relevant constructor so self.base_url stores the raw kwargs["base_url"] value,
then pass that unmodified value into both AzureOpenAI and AsyncAzureOpenAI via
azure_endpoint.
- Around line 735-736: The Ollama client initialization in CVModel is passing a
versioned URL through ensure_v1, which breaks native Ollama requests. Update the
host setup in the initializer that assigns self.base_url and creates self.client
so it uses the raw base URL from kwargs["base_url"] directly, and keep
Client(host=...) pointed at the Ollama server root without appending /v1.
In `@rag/llm/embedding_model.py`:
- Around line 472-473: The Ollama client setup is rewriting the server URL with
ensure_v1, which breaks native embedding requests. Update the client
initialization in the embedding model path so Client(host=...) receives the raw
base_url from kwargs without ensure_v1, and make the same change in the
corresponding Client(host=...) setup in cv_model to keep both Ollama
integrations consistent.
- Around line 325-327: The Azure endpoint setup in the embedding model
initialization is still passing the endpoint through ensure_v1, which should be
removed because AzureOpenAI expects the raw resource URL. Update the code path
that assigns self.base_url and constructs AzureOpenAI so it uses the original
kwargs["base_url"] directly as azure_endpoint, while keeping api_version
handling unchanged. Focus on the embedding_model initialization logic around
self.client and ensure the base URL is not version-suffixed anywhere in that
flow.
In `@rag/llm/sequence2txt_model.py`:
- Line 149: The Xinference speech-to-text request URL is building `/v1` twice
because `ensure_v1` already normalizes `self.base_url` in `XinferenceSeq2txt`,
while `transcription()` still hardcodes another `/v1` segment. Update
`XinferenceSeq2txt.transcription()` to construct the audio transcription
endpoint from the normalized `self.base_url` without adding an extra `/v1`, so
the final path resolves correctly for all Xinference base URLs.
- Around line 139-140: The AzureOpenAI setup in the sequence-to-text model is
mutating the Azure endpoint with ensure_v1, which breaks transcription requests
by changing the resource root URL. Update the initialization in the
sequence2txt_model path so self.base_url keeps the original kwargs["base_url"]
value and pass that directly into AzureOpenAI via azure_endpoint, leaving the
rest of the client construction unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1199e2b6-4555-4e95-bcd9-b81b22f3e4c3
📒 Files selected for processing (7)
conf/llm_factories.jsonrag/llm/chat_model.pyrag/llm/cv_model.pyrag/llm/embedding_model.pyrag/llm/sequence2txt_model.pyrag/llm/tts_model.pyrag/utils/url_utils.py
| self.base_url = ensure_v1(kwargs["base_url"]) | ||
| self.client = AzureOpenAI(api_key=api_key, azure_endpoint=self.base_url, api_version=api_version) | ||
| self.async_client = AsyncAzureOpenAI(api_key=api_key, azure_endpoint=self.base_url, api_version=api_version) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify Azure OpenAI endpoint URL structure expected by the openai library.
# Check if azure_endpoint with an appended /v1 path would break URL construction.
rg -n "azure_endpoint" --type=py -g '!**/test/**' -C3 | head -40Repository: infiniflow/ragflow
Length of output: 156
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the relevant file and helper definitions/call sites.
git ls-files rag/llm/cv_model.py
printf '\n--- cv_model.py (around the cited lines) ---\n'
sed -n '280,340p' rag/llm/cv_model.py
printf '\n--- ensure_v1 definition/call sites ---\n'
rg -n "def ensure_v1|ensure_v1\(" rag -SRepository: infiniflow/ragflow
Length of output: 5875
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n--- rag/utils/url_utils.py ---\n'
sed -n '1,120p' rag/utils/url_utils.py
printf '\n--- AzureOpenAI references in repo ---\n'
rg -n "AzureOpenAI|AsyncAzureOpenAI|azure_endpoint" rag -SRepository: infiniflow/ragflow
Length of output: 2825
Remove ensure_v1 from the Azure endpoint rag/llm/cv_model.py:314-316 — AzureOpenAI(azure_endpoint=...) expects the raw Azure resource URL, and ensure_v1() rewrites it to .../v1, which breaks the request path (.../v1/openai/deployments/...).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rag/llm/cv_model.py` around lines 314 - 316, The Azure client setup in
cv_model.py is rewriting the endpoint with ensure_v1(), which breaks AzureOpenAI
and AsyncAzureOpenAI request paths by appending an invalid /v1 segment. Update
the initialization in the relevant constructor so self.base_url stores the raw
kwargs["base_url"] value, then pass that unmodified value into both AzureOpenAI
and AsyncAzureOpenAI via azure_endpoint.
| self.base_url = ensure_v1(kwargs["base_url"]) | ||
| self.client = Client(host=self.base_url) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify how ollama.Client constructs request URLs from the host parameter.
rg -n "Client" --type=py rag/llm/cv_model.py -C5 | head -30Repository: infiniflow/ragflow
Length of output: 1304
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate ensure_v1 and Ollama-related usage.
rg -n "def ensure_v1|ensure_v1\(|OllamaCV|ollama" rag -C 3
# Show the relevant section around ensure_v1 if it exists.
file=$(rg -l "def ensure_v1" rag | head -n 1 || true)
if [ -n "${file:-}" ]; then
echo "=== $file ==="
lineno=$(rg -n "def ensure_v1" "$file" | head -n 1 | cut -d: -f1)
start=$((lineno-20)); [ "$start" -lt 1 ] && start=1
end=$((lineno+40))
sed -n "${start},${end}p" "$file"
fiRepository: infiniflow/ragflow
Length of output: 22281
🌐 Web query:
Ollama Python client host parameter base URL /api/generate /v1 docs source
💡 Result:
The Ollama Python client uses the host parameter in the Client constructor to define the base URL of the Ollama server [1][2][3]. By default, if the host parameter is not provided, the client defaults to http://127.0.0.1:11434, or it reads from the OLLAMA_HOST environment variable if set [4][2]. To connect to a custom or remote Ollama server, you should instantiate a new Client instead of using the module-level functions [5][6]. Example of configuring a custom host: from ollama import Client client = Client( host='http://your-remote-server:11434') response = client.generate(model='llama3.2', prompt='Why is the sky blue?') Key Technical Details: - Parameter: The host parameter accepts a string representing the server address [2][7]. The library internally uses a _parse_host utility to normalize inputs (e.g., adding http:// if missing, defaulting the port to 11434 if not specified) [4][2]. - API Endpoints: The Ollama Python client maps its methods directly to the Ollama REST API [3]. When you call client.generate, the library makes a request to the /api/generate endpoint on the specified host [8][9]. The client library handles the construction of the full URL (e.g., http://your-host:11434/api/generate) automatically [7]. - V1 Compatibility: While the primary Ollama API is accessed via /api/generate, the client library is designed to interact with the standard Ollama API architecture [10][9]. If you are looking for OpenAI-compatible V1 endpoints (e.g., /v1/chat/completions), these are typically handled by the Ollama server itself (which exposes a subset of OpenAI-compatible routes), but the official ollama-python client is primarily optimized for the native /api/ routes [11][8][3]. For advanced configurations, all keyword arguments passed to the Client constructor are forwarded to the underlying httpx.Client, allowing for further customization such as timeouts or proxy settings [1][2][3].
Citations:
- 1: https://github.com/ollama/ollama-python?tab=readme-ov-file
- 2: https://deepwiki.com/ollama/ollama-python/5.2-configuration-and-options
- 3: https://pypi.org/project/ollama/0.4.7/
- 4: https://github.com/ollama/ollama-python/blob/main/ollama/_client.py
- 5: How do I define the 'base_url' using embeddings() ollama/ollama-python#77
- 6: https://markaicode.com/ollama-python-library-api-reference/
- 7: https://theneuralbase.com/ollama/learn/advanced/remote-client-configuration/
- 8: https://github.com/ollama/ollama/blob/main/docs/api.md
- 9: https://ollama.readthedocs.io/en/api/
- 10: https://docs.ollama.com/api/introduction
- 11: https://docs.ollama.com/api/generate
Remove ensure_v1 from the Ollama host (rag/llm/cv_model.py:735-736) ollama.Client(host=...) needs the raw Ollama server root (for example http://localhost:11434); adding /v1 sends native requests to /v1/api/... and will 404.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rag/llm/cv_model.py` around lines 735 - 736, The Ollama client initialization
in CVModel is passing a versioned URL through ensure_v1, which breaks native
Ollama requests. Update the host setup in the initializer that assigns
self.base_url and creates self.client so it uses the raw base URL from
kwargs["base_url"] directly, and keep Client(host=...) pointed at the Ollama
server root without appending /v1.
| self.base_url = ensure_v1(kwargs["base_url"]) | ||
| self.client = AzureOpenAI(api_key=api_key, azure_endpoint=self.base_url, api_version=api_version) | ||
|
|
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== embedding_model.py around target ==\n'
nl -ba rag/llm/embedding_model.py | sed -n '280,360p'
printf '\n== cv_model.py around Azure handling ==\n'
nl -ba rag/llm/cv_model.py | sed -n '1,260p'
printf '\n== ensure_v1 references ==\n'
rg -n "def ensure_v1|ensure_v1\(" rag -SRepository: infiniflow/ragflow
Length of output: 236
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== embedding_model.py around target ==\n'
awk 'NR>=280 && NR<=360 { printf "%d:%s\n", NR, $0 }' rag/llm/embedding_model.py
printf '\n== cv_model.py around Azure handling ==\n'
awk 'NR>=1 && NR<=260 { printf "%d:%s\n", NR, $0 }' rag/llm/cv_model.py
printf '\n== ensure_v1 references ==\n'
rg -n "def ensure_v1|ensure_v1\(" rag -SRepository: infiniflow/ragflow
Length of output: 17385
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== ensure_v1 implementation ==\n'
awk 'NR>=1 && NR<=120 { printf "%d:%s\n", NR, $0 }' rag/utils/url_utils.py
printf '\n== embedding_model.py Azure/base_url related constructors ==\n'
awk 'NR>=240 && NR<=340 { printf "%d:%s\n", NR, $0 }' rag/llm/embedding_model.py
printf '\n== Azure-related embedding constructors in file ==\n'
rg -n "Azure|azure_endpoint|api_version|base_url" rag/llm/embedding_model.pyRepository: infiniflow/ragflow
Length of output: 16907
🏁 Script executed:
#!/bin/bash
set -euo pipefail
awk 'NR>=1 && NR<=120 { printf "%d:%s\n", NR, $0 }' rag/utils/url_utils.pyRepository: infiniflow/ragflow
Length of output: 2113
🌐 Web query:
AzureOpenAI azure_endpoint base URL without /v1 openai python sdk documentation
💡 Result:
When using the OpenAI Python SDK to connect to Azure OpenAI, you have two primary options for specifying your endpoint. The behavior regarding the /v1 path depends on which parameter you use [1][2]. 1. Using the azure_endpoint parameter (Recommended for Azure) When using the AzureOpenAI client, the azure_endpoint parameter expects the base resource URL without the /v1 suffix (e.g., https://{resource-name}.openai.azure.com/) [1][3][4]. The SDK automatically appends the necessary path segments (such as /openai/deployments/{deployment-name} or /openai) to construct the final URL [5][2]. 2. Using the base_url parameter If you prefer or need to specify the full URL manually—for example, if you are using a custom endpoint or specific API versioning patterns—you can use the base_url parameter instead of azure_endpoint [1][2]. In this case, you must provide the full path, including /openai/v1/ (e.g., https://{resource-name}.openai.azure.com/openai/v1/) [6][7]. Unlike azure_endpoint, the base_url parameter does not automatically append the /openai/ segment [1]. Key Differences - azure_endpoint: Designed for Azure OpenAI; the SDK handles path construction automatically [1][2]. - base_url: A lower-level override; you are responsible for providing the complete URL path [1][2]. These parameters are mutually exclusive; you must choose one or the other [2]. If you are migrating to the standard OpenAI client (instead of AzureOpenAI), you will typically use base_url and must explicitly include /openai/v1/ in the URL [6][7].
Citations:
- 1: Fix Azure Client /openai/deployments route override to be used more w… openai/openai-python#1836
- 2: https://github.com/openai/openai-python/blob/722d3fff/src/openai/lib/azure.py
- 3: https://github.com/openai/openai-python?azure-portal=true
- 4: https://github.com/openai/openai-cookbook/blob/main/examples/azure/chat.ipynb
- 5: https://github.com/openai/openai-python/blob/5e8f09c2/src/openai/lib/azure.py
- 6: https://learn.microsoft.com/en-us/azure/foundry/openai/api-version-lifecycle
- 7: https://learn.microsoft.com/en-us/azure/ai-foundry/how-to/model-inference-to-openai-migration?view=foundry-classic
Remove ensure_v1 from the Azure endpoint.
AzureOpenAI(azure_endpoint=...) expects the raw Azure resource URL; appending /v1 breaks Azure endpoints that don’t already include a versioned path.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rag/llm/embedding_model.py` around lines 325 - 327, The Azure endpoint setup
in the embedding model initialization is still passing the endpoint through
ensure_v1, which should be removed because AzureOpenAI expects the raw resource
URL. Update the code path that assigns self.base_url and constructs AzureOpenAI
so it uses the original kwargs["base_url"] directly as azure_endpoint, while
keeping api_version handling unchanged. Focus on the embedding_model
initialization logic around self.client and ensure the base URL is not
version-suffixed anywhere in that flow.
| self.base_url = ensure_v1(kwargs["base_url"]) | ||
| self.client = Client(host=self.base_url) if not key or key == "x" else Client(host=self.base_url, headers={"Authorization": f"Bearer {key}"}) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== embedding_model.py around the referenced lines ==\n'
nl -ba rag/llm/embedding_model.py | sed -n '430,500p'
printf '\n== cv_model.py around the Ollama client setup ==\n'
nl -ba rag/llm/cv_model.py | sed -n '1,220p'
printf '\n== search for ensure_v1 usage and definition ==\n'
rg -n "ensure_v1|Client\(host=|ollama" rag/llm -S
printf '\n== search for Ollama URL handling docs/comments in repo ==\n'
rg -n "v1|native API|Ollama" -S README.md rag || trueRepository: infiniflow/ragflow
Length of output: 250
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== embedding_model.py around the referenced lines ==\n'
sed -n '450,490p' rag/llm/embedding_model.py
printf '\n== cv_model.py Ollama setup ==\n'
sed -n '1,220p' rag/llm/cv_model.py
printf '\n== ensure_v1 definition and usages ==\n'
rg -n "def ensure_v1|ensure_v1\(|Client\(host=|ollama" rag/llm -S
printf '\n== repository mentions of Ollama URL expectations ==\n'
rg -n "Ollama|native API|/v1" -S README.md rag || trueRepository: infiniflow/ragflow
Length of output: 35196
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== ensure_v1 helper ==\n'
sed -n '1,140p' rag/utils/url_utils.py
printf '\n== OllamaEmbed class context ==\n'
sed -n '460,510p' rag/llm/embedding_model.py
printf '\n== OllamaCV class context ==\n'
sed -n '728,745p' rag/llm/cv_model.pyRepository: infiniflow/ragflow
Length of output: 4849
Remove ensure_v1 from the Ollama client host
ollama.Client(host=...) should get the raw server URL. ensure_v1() rewrites host-only URLs to .../v1, which breaks native Ollama embedding requests; the same pattern exists in rag/llm/cv_model.py.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rag/llm/embedding_model.py` around lines 472 - 473, The Ollama client setup
is rewriting the server URL with ensure_v1, which breaks native embedding
requests. Update the client initialization in the embedding model path so
Client(host=...) receives the raw base_url from kwargs without ensure_v1, and
make the same change in the corresponding Client(host=...) setup in cv_model to
keep both Ollama integrations consistent.
| self.base_url = ensure_v1(kwargs["base_url"]) | ||
| self.client = AzureOpenAI(api_key=key, azure_endpoint=self.base_url, api_version="2024-02-01") |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n## Files\n'
git ls-files 'rag/llm/*.py' | sed 's#^`#-` #'
printf '\n## Search ensure_v1 usages\n'
rg -n "ensure_v1|AzureOpenAI|azure_endpoint|base_url" rag/llm -S
printf '\n## ensure_v1 definition if present\n'
rg -n "def ensure_v1|ensure_v1\(" -S .Repository: infiniflow/ragflow
Length of output: 50374
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n## sequence2txt_model.py\n'
nl -ba rag/llm/sequence2txt_model.py | sed -n '120,170p'
printf '\n## cv_model.py\n'
nl -ba rag/llm/cv_model.py | sed -n '1,220p'
printf '\n## embedding_model.py\n'
nl -ba rag/llm/embedding_model.py | sed -n '1,220p'
printf '\n## ensure_v1 definition\n'
rg -n "def ensure_v1|class .*ensure_v1|ensure_v1 =" -S . -g '!**/.git/**'Repository: infiniflow/ragflow
Length of output: 222
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n## Search for AzureOpenAI docs or comments in repo\n'
rg -n "AzureOpenAI|api_version|azure resource URL|/v1" -S README.md rag tests .github docs 2>/dev/null || true
printf '\n## Look for sequence2txt_model call sites/config examples\n'
rg -n "sequence2txt|Sequence2Txt|base_url" -S rag tests README.md .github docs 2>/dev/null || trueRepository: infiniflow/ragflow
Length of output: 50375
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
for path in [
Path("rag/llm/sequence2txt_model.py"),
Path("rag/llm/cv_model.py"),
Path("rag/llm/embedding_model.py"),
]:
print(f"\n## {path}")
text = path.read_text()
for i, line in enumerate(text.splitlines(), 1):
if "ensure_v1" in line or "AzureOpenAI" in line or "azure_endpoint" in line or "base_url" in line:
print(f"{i}: {line}")
PYRepository: infiniflow/ragflow
Length of output: 21650
Drop ensure_v1 before constructing AzureOpenAI here. azure_endpoint must stay as the Azure resource root URL; appending /v1 breaks Azure transcription requests.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rag/llm/sequence2txt_model.py` around lines 139 - 140, The AzureOpenAI setup
in the sequence-to-text model is mutating the Azure endpoint with ensure_v1,
which breaks transcription requests by changing the resource root URL. Update
the initialization in the sequence2txt_model path so self.base_url keeps the
original kwargs["base_url"] value and pass that directly into AzureOpenAI via
azure_endpoint, leaving the rest of the client construction unchanged.
|
|
||
| def __init__(self, key, model_name="whisper-small", **kwargs): | ||
| self.base_url = kwargs.get("base_url", None) | ||
| self.base_url = ensure_v1(kwargs["base_url"]) if kwargs.get("base_url") else None |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Double /v1 path in XinferenceSeq2txt.transcription().
ensure_v1 on line 149 appends /v1 to self.base_url, but the unchanged transcription() method on line 167 still prepends /v1 manually: f"{self.base_url}/v1/audio/transcriptions". This produces a double /v1 (e.g., https://example.com/v1/v1/audio/transcriptions) for any input URL, breaking all Xinference speech-to-text requests.
🐛 Proposed fix: remove manual /v1 from transcription URL
Apply this change to the unchanged transcription() method (line 167) to eliminate the double /v1:
- response = requests.post(f"{self.base_url}/v1/audio/transcriptions", files=files, data=payload, timeout=60)
+ response = requests.post(f"{self.base_url}/audio/transcriptions", files=files, data=payload, timeout=60)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| self.base_url = ensure_v1(kwargs["base_url"]) if kwargs.get("base_url") else None | |
| response = requests.post(f"{self.base_url}/audio/transcriptions", files=files, data=payload, timeout=60) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rag/llm/sequence2txt_model.py` at line 149, The Xinference speech-to-text
request URL is building `/v1` twice because `ensure_v1` already normalizes
`self.base_url` in `XinferenceSeq2txt`, while `transcription()` still hardcodes
another `/v1` segment. Update `XinferenceSeq2txt.transcription()` to construct
the audio transcription endpoint from the normalized `self.base_url` without
adding an extra `/v1`, so the final path resolves correctly for all Xinference
base URLs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16774 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Make
/v1inbase_urloptional.