From 16082222e2c3654daaf6bfb47545a03207d15717 Mon Sep 17 00:00:00 2001 From: Mrityunjay Raj Date: Fri, 2 Jan 2026 21:56:49 +0530 Subject: [PATCH] Fix get_advisory_url to handle string file paths The function now accepts both Path objects and strings for the `file` and `base_path` parameters, converting strings to Path objects before calling relative_to(). This fixes the AttributeError that occurred when importers passed string paths instead of Path objects. Fixes: #2016 Signed-off-by: Mrityunjay Raj --- vulnerabilities/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vulnerabilities/utils.py b/vulnerabilities/utils.py index 999244498..7a03fc2ee 100644 --- a/vulnerabilities/utils.py +++ b/vulnerabilities/utils.py @@ -19,6 +19,7 @@ from collections import defaultdict from functools import total_ordering from http import HTTPStatus +from pathlib import Path from typing import List from typing import Optional from typing import Tuple @@ -543,6 +544,10 @@ def get_advisory_url(file, base_path, url): """ Return the advisory URL constructed by combining the base URL with the relative file path. """ + if isinstance(file, str): + file = Path(file) + if isinstance(base_path, str): + base_path = Path(base_path) relative_path = str(file.relative_to(base_path)).strip("/") advisory_url = urljoin(url, relative_path) return advisory_url