Repository navigation
Conversation
There was a problem hiding this comment.
🤖 AI code review
This PR aligns the HTTPS failure path of _run_clone_command_silent in both sagemaker-train and sagemaker-core with sagemaker.core.git_utils._run_clone_command: it redacts credentials from the URL via the existing _redact_credentials_from_url helper, reconstructs a CalledProcessError with the sanitized command, logs the safe URL, and re-raises from None. The SSH path is correctly left unchanged, consistent with prior git_utils work (PR #5811/#5812). New unit tests cover sanitized-failure, plain-URL, and success cases in both modules. The change is correct, well-scoped, and adequately tested; I found no issues.
Reviewed commit b8cb194. Automated review; verify before acting.
There was a problem hiding this comment.
🤖 AI code review
This PR aligns the two _run_clone_command_silent copies (sagemaker-train and sagemaker-core modules) with git_utils._run_clone_command: on an HTTPS clone failure it now redacts credentials from the URL, re-raises a reconstructed CalledProcessError ... from None, and logs the redacted URL. It also tightens the shared _redact_credentials_from_url regex so only the authority's userinfo (before the first /, ? or #) is redacted, fixing false-positive redaction of a later @ in a path/query/fragment. The change is correct, consistent with the established credential-redaction precedent, and well covered by new unit tests for both copies plus the regex. No code defects found.
The regex change in git_utils.py alters the behavior of the existing _run_clone_command path too — a correct improvement, but the PR body describes only the two utils.py copies, so reviewers may overlook it.
Reviewed commit 2ee095b. Automated review; verify before acting.
| url (str): The Git repository URL that may contain embedded credentials. | ||
|
|
||
| Returns: | ||
| str: The URL with credentials replaced by '<credentials-redacted>'. |
There was a problem hiding this comment.
🟡 Low: This regex change to _redact_credentials_from_url is a behavior change to the shared helper and therefore also affects the existing _run_clone_command HTTPS path, not just the two new _run_clone_command_silent copies described in the PR summary. The new pattern is an improvement (the old greedy [^@]+@ would wrongly redact a URL like https://github.com/user/repo@v1.git up to the @ in the path), and it's covered by the new tests. Consider calling out this git_utils.py change explicitly in the PR description so reviewers don't miss that the canonical redaction behavior changed.
There was a problem hiding this comment.
🤖 AI code review
This PR aligns the Training Recipes _run_clone_command_silent helpers (in sagemaker-train and sagemaker-core) with git_utils._run_clone_command: on an HTTPS clone failure they now redact credentials via _redact_credentials_from_url and re-raise a reconstructed CalledProcessError ... from None. It also tightens the redaction regex to ^(https://)[^/?#]*@ so passwords containing @ are fully redacted and @ signs in the path/query/fragment are not mistaken for userinfo. The change is consistent with prior precedent (Source: #5811, Source: #5812), SSH paths are correctly left unchanged, and the new unit tests cover the userinfo, no-userinfo, and success cases plus the regex edge cases. I found no correctness, security, or test-coverage issues.
Reviewed commit 81d6cb6. Automated review; verify before acting.
Summary
The Training Recipes clone helper
_run_clone_command_silentexists in two places (sagemaker-trainandsagemaker-coremodules). Its HTTPS failure handling has drifted fromsagemaker.core.git_utils._run_clone_command. This change brings both copies in line withgit_utils, so a failed recipe clone produces the same URL formatting and exception shape everywhere in the SDK.Changes
sagemaker-train/src/sagemaker/train/utils.pyandsagemaker-core/src/sagemaker/core/modules/utils.py:sagemaker.core.git_utilswhen reporting an HTTPS clone failure.CalledProcessErrorbuilt from the formatted URL (from None). This matchesgit_utils._run_clone_commandand keeps tracebacks to a single, clean exception.Testing
sagemaker-train/tests/unit/train/test_utils_clone.pyandsagemaker-core/tests/unit/modules/test_utils_clone.py, which cover:git clone,GIT_TERMINAL_PROMPT=0still set)sagemaker-trainrecipe tests,sagemaker-coretests/unit/modules, andtests/unit/test_git_utils.py.blackandflake8are clean on the changed files.