From cad2871391e22dfb2e4a8fcb7ecd073f574dfd3a Mon Sep 17 00:00:00 2001 From: rshunim Date: Thu, 1 Jan 2026 18:01:51 +0200 Subject: [PATCH 1/3] my-changes-from-1.38.16 --- .../commands/content_graph/commands/update.py | 14 ++++++++++++-- demisto_sdk/commands/validate/initializer.py | 2 +- .../commands/validate/validators/base_validator.py | 11 +++++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/demisto_sdk/commands/content_graph/commands/update.py b/demisto_sdk/commands/content_graph/commands/update.py index f4440715901..b83fb68f581 100644 --- a/demisto_sdk/commands/content_graph/commands/update.py +++ b/demisto_sdk/commands/content_graph/commands/update.py @@ -97,8 +97,18 @@ def update_content_graph( logger.info("A path to import the graph from was not provided, using git") use_git = True - git_util = GitUtil() - is_external_repo = is_external_repository() + try: + git_util = GitUtil() + is_external_repo = is_external_repository() + except Exception as e: + logger.debug( + f"Could not initialize GitUtil: {e}. Assuming external repo and skipping git operations." + ) + # If git is not available, we can't use git-based updates + # This can happen in CI/CD environments where the working directory is not a git repo + use_git = False + git_util = None # type: ignore[assignment] + is_external_repo = True if is_external_repo: packs_to_update = get_all_repo_pack_ids() diff --git a/demisto_sdk/commands/validate/initializer.py b/demisto_sdk/commands/validate/initializer.py index c7a58eda924..24c9647ab4e 100644 --- a/demisto_sdk/commands/validate/initializer.py +++ b/demisto_sdk/commands/validate/initializer.py @@ -743,7 +743,7 @@ def git_paths_to_basecontent_set( old_path = file_path if isinstance(file_path, tuple): file_path, old_path = file_path - obj = BaseContent.from_path(file_path, raise_on_exception=True) + obj = BaseContent.from_path(file_path, git_sha=None, raise_on_exception=True) if obj: obj.git_sha = current_git_sha obj.git_status = git_status diff --git a/demisto_sdk/commands/validate/validators/base_validator.py b/demisto_sdk/commands/validate/validators/base_validator.py index 9b29d60293b..4c155fbe833 100644 --- a/demisto_sdk/commands/validate/validators/base_validator.py +++ b/demisto_sdk/commands/validate/validators/base_validator.py @@ -176,10 +176,13 @@ def graph(self) -> ContentGraphInterface: if not self.graph_interface: logger.info("Graph validations were selected, will init graph") BaseValidator.graph_interface = ContentGraphInterface() - update_content_graph( - BaseValidator.graph_interface, - use_git=True, - ) + # Only update the graph if it's not already alive/initialized + # This prevents re-running git operations that may fail in CI/CD environments + if not BaseValidator.graph_interface.is_alive(): + update_content_graph( + BaseValidator.graph_interface, + use_git=True, + ) return self.graph_interface def __dir__(self): From 694055b86fe278150c2d2c6e220a87e846c60f2d Mon Sep 17 00:00:00 2001 From: rshunim Date: Thu, 1 Jan 2026 18:04:50 +0200 Subject: [PATCH 2/3] mypy --- demisto_sdk/commands/content_graph/commands/update.py | 11 ++++++++--- demisto_sdk/commands/validate/initializer.py | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/demisto_sdk/commands/content_graph/commands/update.py b/demisto_sdk/commands/content_graph/commands/update.py index b83fb68f581..31dc9e035e7 100644 --- a/demisto_sdk/commands/content_graph/commands/update.py +++ b/demisto_sdk/commands/content_graph/commands/update.py @@ -30,11 +30,11 @@ def should_update_graph( content_graph_interface: ContentGraphInterface, use_git: bool, - git_util: GitUtil, + git_util: Optional[GitUtil], imported_path: Optional[Path] = None, packs_to_update: Optional[List[str]] = None, ): - if content_graph_interface.commit: + if content_graph_interface.commit and git_util: try: changed_pack_ids = git_util.get_all_changed_pack_ids( content_graph_interface.commit @@ -155,7 +155,12 @@ def update_content_graph( content_graph_interface, marketplace, dependencies, output_path ) return - if use_git and (commit := content_graph_interface.commit) and not is_external_repo: + if ( + use_git + and (commit := content_graph_interface.commit) + and not is_external_repo + and git_util + ): try: git_util.get_all_changed_pack_ids(commit) except Exception as e: diff --git a/demisto_sdk/commands/validate/initializer.py b/demisto_sdk/commands/validate/initializer.py index 24c9647ab4e..6be0b24a757 100644 --- a/demisto_sdk/commands/validate/initializer.py +++ b/demisto_sdk/commands/validate/initializer.py @@ -743,7 +743,9 @@ def git_paths_to_basecontent_set( old_path = file_path if isinstance(file_path, tuple): file_path, old_path = file_path - obj = BaseContent.from_path(file_path, git_sha=None, raise_on_exception=True) + obj = BaseContent.from_path( + file_path, git_sha=None, raise_on_exception=True + ) if obj: obj.git_sha = current_git_sha obj.git_status = git_status From 332a4cbf10986b08a5b73d189366d28170c63c81 Mon Sep 17 00:00:00 2001 From: rshunim Date: Thu, 1 Jan 2026 18:18:49 +0200 Subject: [PATCH 3/3] add a check to the condition --- demisto_sdk/commands/content_graph/commands/update.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/demisto_sdk/commands/content_graph/commands/update.py b/demisto_sdk/commands/content_graph/commands/update.py index 31dc9e035e7..1902401d866 100644 --- a/demisto_sdk/commands/content_graph/commands/update.py +++ b/demisto_sdk/commands/content_graph/commands/update.py @@ -114,7 +114,8 @@ def update_content_graph( packs_to_update = get_all_repo_pack_ids() packs_to_update = list(packs_to_update) if packs_to_update else [] builder = ContentGraphBuilder(content_graph_interface) - if not should_update_graph( + # If git_util is None, we can't check if we should update, so assume we should not + if git_util and not should_update_graph( content_graph_interface, use_git, git_util, imported_path, packs_to_update ): logger.info(