Add info to failed check runs if clone the repository failed.#678
Add info to failed check runs if clone the repository failed.#678
Conversation
|
Report bugs in Issues The following are automatically added:
Available user actions:
Supported /retest check runs
Supported labels
|
WalkthroughThis pull request refactors error handling within the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (4)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
webhook_server_container/libs/github_api.py (1)
1740-1765: Enhanced security by masking sensitive information in error messages.The
get_check_run_textmethod has been updated to mask sensitive information like tokens and credentials before returning the output. This is an important security improvement that prevents accidental exposure of sensitive data in logs and error messages.Consider using a more generic approach to mask sensitive tokens:
- if self.pypi and self.pypi.get("token"): - _output = _output.replace(self.pypi["token"], _hased_str) - - if self.container_repository_username: - _output = _output.replace(self.container_repository_username, _hased_str) - - if self.container_repository_password: - _output = _output.replace(self.container_repository_password, _hased_str) - - if self.token: - _output = _output.replace(self.token, _hased_str) - - if self.jira_token: - _output = _output.replace(self.jira_token, _hased_str) + # Define a list of sensitive tokens to mask + sensitive_tokens = [ + self.pypi.get("token") if self.pypi else None, + self.container_repository_username if hasattr(self, "container_repository_username") else None, + self.container_repository_password if hasattr(self, "container_repository_password") else None, + self.token if hasattr(self, "token") else None, + self.jira_token if hasattr(self, "jira_token") else None + ] + + # Replace all non-empty tokens with masked string + for token in sensitive_tokens: + if token: + _output = _output.replace(token, _hased_str)This approach is more maintainable as you only need to add new tokens to the list if additional sensitive information needs to be masked in the future.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
webhook_server_container/libs/github_api.py(9 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: tox
- GitHub Check: build-container
- GitHub Check: pre-commit
- GitHub Check: python-module-install
🔇 Additional comments (9)
webhook_server_container/libs/github_api.py (9)
544-551: New unified error handling implementation.The introduction of
_issue_on_errorconsolidates error handling by providing a centralized function to create issues when errors occur. This improves consistency and reduces code duplication across various methods.
558-562: Improved error handling for repository cloning.The code now properly captures and handles repository cloning failures by checking the result of
_prepare_cloned_repo_dir. When the operation fails, it creates an issue with detailed error information which directly addresses the PR objective.
1067-1076: Enhanced error handling for tox testing.Error handling has been improved in the
_run_toxmethod by checking the result of repository preparation and providing detailed error information in the check run output. This ensures that users can see precise errors when repository cloning fails during tox testing.
1097-1106: Enhanced error handling for pre-commit checks.Similar to the tox testing, pre-commit check handling has been improved to capture and report detailed errors when repository preparation fails. This provides better visibility into the root cause of failures.
1243-1252: Improved error handling for cherry-pick operations.The cherry-pick operation now properly captures and reports repository cloning failures, providing more detailed information in the check run status. This is consistent with the overall error handling improvements in the PR.
1459-1472: Enhanced error reporting for container builds.The error handling for container build operations has been improved to capture repository cloning failures and report them properly in the check run output. This provides better visibility when builds fail due to repository preparation issues.
1525-1534: Improved error handling for Python module installation.The
_run_install_python_modulemethod now properly handles repository cloning failures and reports detailed error information in the check run output, which is consistent with the other improvements in this PR.
1654-1654: Return type enhancement for better error handling.The return type of
_prepare_cloned_repo_dirhas been changed to return a tuple containing a boolean success indicator and additional error context (output and error messages). This allows calling methods to better understand and handle failures.
1658-1686: Improved error propagation in repository preparation.The code now properly propagates errors encountered during the repository preparation process by yielding the result of each operation. This enables calling methods to receive detailed error information when specific steps fail, fulfilling the PR objective of improving error messages for repository cloning issues.
|
/verified |
|
New container for ghcr.io/myk-org/github-webhook-server:latest published |
Clone repository have few steps, and it's called by each check run.
If one of the steps fail we will add the error to the check run details.
Summary by CodeRabbit