Skip to content

Commit a2e8e55

Browse files
Improve path construction robustness in fetch_one
- Use rstrip('/') on base_path and lstrip('/') on pk segments - More robust than replace('//', '/') for handling edge cases - Addresses Copilot review feedback Co-Authored-By: AJ Steers <[email protected]>
1 parent bab2781 commit a2e8e55

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

airbyte_cdk/sources/declarative/retrievers/simple_retriever.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,11 +675,11 @@ def fetch_one(
675675
)
676676

677677
if isinstance(pk_value, str):
678-
fetch_path = f"{base_path}/{pk_value}".replace("//", "/")
678+
fetch_path = f"{base_path.rstrip('/')}/{str(pk_value).lstrip('/')}"
679679
elif isinstance(pk_value, Mapping):
680-
sorted_values = [str(pk_value[key]) for key in sorted(pk_value.keys())]
680+
sorted_values = [str(pk_value[key]).lstrip("/") for key in sorted(pk_value.keys())]
681681
pk_path_segment = "/".join(sorted_values)
682-
fetch_path = f"{base_path}/{pk_path_segment}".replace("//", "/")
682+
fetch_path = f"{base_path.rstrip('/')}/{pk_path_segment}"
683683
else:
684684
raise ValueError(f"pk_value must be a string or dict, got {type(pk_value).__name__}")
685685

0 commit comments

Comments
 (0)