Skip to content

Commit c4b89d6

Browse files
committed
Avoid KeyError
1 parent fe77b24 commit c4b89d6

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

python/runfiles/runfiles.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,9 @@ def Rlocation(self, path: str, source_repo: Optional[str] = None) -> Optional[st
309309

310310
# Look up the target repository using the repository mapping
311311
if source_repo is not None:
312-
try:
313-
target_canonical = self._repo_mapping[(source_repo, target_repo)]
312+
target_canonical = self._repo_mapping.get((source_repo, target_repo))
313+
if target_canonical is not None:
314314
return self._strategy.RlocationChecked(target_canonical + "/" + remainder)
315-
except KeyError:
316-
pass # No mapping found, continue to fallback
317315

318316
# No mapping found - assume target_repo is already canonical or
319317
# we're not using Bzlmod

0 commit comments

Comments
 (0)