Skip to content

Commit 128fa7b

Browse files
authored
Merge pull request #7527 from opsmill/pog-return-early-for-missing-source-branch
Return early for missing source branch
2 parents e1bb469 + acf591e commit 128fa7b

File tree

1 file changed

+9
-3
lines changed
  • backend/infrahub/proposed_change

1 file changed

+9
-3
lines changed

backend/infrahub/proposed_change/tasks.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from typing import TYPE_CHECKING
99

1010
import pytest
11-
from infrahub_sdk.exceptions import ModuleImportError, NodeNotFoundError
11+
from infrahub_sdk.exceptions import ModuleImportError, NodeNotFoundError, URLNotFoundError
1212
from infrahub_sdk.node import InfrahubNode
1313
from infrahub_sdk.protocols import (
1414
CoreArtifactValidator,
@@ -1502,8 +1502,14 @@ async def _get_proposed_change_repositories(
15021502
destination_all = await client.execute_graphql(
15031503
query=DESTINATION_ALLREPOSITORIES, branch_name=model.destination_branch
15041504
)
1505-
source_managed = await client.execute_graphql(query=SOURCE_REPOSITORIES, branch_name=model.source_branch)
1506-
source_readonly = await client.execute_graphql(query=SOURCE_READONLY_REPOSITORIES, branch_name=model.source_branch)
1505+
try:
1506+
source_managed = await client.execute_graphql(query=SOURCE_REPOSITORIES, branch_name=model.source_branch)
1507+
source_readonly = await client.execute_graphql(
1508+
query=SOURCE_READONLY_REPOSITORIES, branch_name=model.source_branch
1509+
)
1510+
except URLNotFoundError:
1511+
# If the URL is not found it means that the source branch has been deleted after the proposed change was created
1512+
return []
15071513

15081514
destination_all = destination_all[InfrahubKind.GENERICREPOSITORY]["edges"]
15091515
source_all = (

0 commit comments

Comments
 (0)