[#314] 🐛 - Error merging release branch after successful deployment#315
Conversation
…Enhance documentation and implementation for deploy label and merge flow. Added new sections in README and index.mdx, and improved MergeRepository to wait for PR-specific check runs before merging. Updated tests for MergeRepository and DeployedActionUseCase to cover new behavior and ensure correctness in handling merges and check waits.
…Enhance MergeRepository and DeployedActionUseCase documentation to clarify PR-specific check run handling and deployment flow. Updated comments and type definitions to reflect new behavior, ensuring better understanding of the merging process and check wait logic.
|
To view this pull requests documentation preview, visit the following URL: Documentation is deployed and generated using docs.page. |
🐛 Bugfix Actions
🚀 Happy coding! |
…Enhance MergeRepository to handle fallback to status checks when no PR-specific check runs are available after polling. Added test case to verify that the merge process correctly waits for pending status checks before proceeding. This improves the robustness of the merging logic and ensures proper handling of check statuses.
…Enhance logging functionality by introducing accumulated log management. Added methods to clear and retrieve accumulated logs, and updated log functions to support accumulation. Implemented tests to verify the correct behavior of log accumulation and formatting, ensuring robust logging capabilities.
…Enhance IssueRepository and publishFindings functionality to support commit SHA watermarks in comments. Updated addComment and updateComment methods to accept an options parameter for commitSha, allowing comments to include a link to the specific commit. Adjusted related tests to verify the inclusion of watermarks in comment bodies.
…Enhance tests for DetectPotentialProblemsUseCase by mocking GitHub actions context to handle undefined SHA. This improves test reliability and ensures proper handling of commit context in potential problem detection.
…Fix commit URL generation to properly encode owner and repository names. Added tests to verify URL encoding for special characters in commit links.
…Fix commit URL generation in CLI and GitHub action files to properly encode owner and repository names, ensuring correct handling of special characters in URLs.
| // multiple PRs (e.g. release→master and release→develop), listForRef returns runs | ||
| // for all PRs; we must wait for runs tied to the current PR or we may see completed | ||
| // runs from the other PR and merge before this PR's checks have run. | ||
| const runsForThisPr = (checkRuns.check_runs as Array<{ status: string; conclusion: string | null; name: string; pull_requests?: Array<{ number: number }> }>).filter( |
There was a problem hiding this comment.
Unsafe type assertion on check_runs
Severity: medium
Location: src/data/repository/merge_repository.ts:90
Line 90 uses a type assertion (checkRuns.check_runs as Array<...>) without runtime validation. If the GitHub API returns unexpected data (e.g., null, undefined, or non-array), this could cause runtime errors. The assertion assumes the structure will always match the expected type.
Suggested fix:
Replace the type assertion with runtime validation. Add a check to ensure checkRuns.check_runs is an array before filtering, and handle cases where it might be null or undefined.
Written by vypdev/copilot for commit 4ce66f2628f4a4fa96315df927b7768f21f0e6e3. This will update automatically on new commits.
| metadata?: Record<string, unknown>; | ||
| } | ||
|
|
||
| const accumulatedLogEntries: LogEntry[] = []; |
There was a problem hiding this comment.
Unbounded log entries array growth
Severity: medium
Location: src/utils/logger.ts:12
The accumulatedLogEntries array at line 12 can grow indefinitely without any size limit or automatic cleanup mechanism. In long-running processes, this could lead to memory exhaustion. While clearAccumulatedLogs() is available, it's not automatically called on a schedule or when the array reaches a certain size.
Suggested fix:
Add a maximum size limit for the array (e.g., 1000 entries) and implement automatic cleanup of old entries when the limit is exceeded, or clear the array periodically.
Written by vypdev/copilot for commit 4ce66f2628f4a4fa96315df927b7768f21f0e6e3. This will update automatically on new commits.
…Enhance publishFindings tests to validate commitSha handling in comments and overflow scenarios. Added cases for using commitSha as a watermark, passing it to addComment and updateComment, and ensuring correct behavior when findings lack associated files. Improved test coverage for comment creation logic in various conditions.
…Refactor publishFindings to improve commitSha handling in comments. Updated logic to ensure correct behavior in scenarios with missing associated files and added tests for various conditions, enhancing overall test coverage.
…Enhance ContentInterface tests to improve error handling and logging. Added test cases for scenarios where extraction and update operations throw errors, ensuring that errors are logged appropriately and that the functions return undefined as expected. This improves the robustness of the content handling logic.
…Enhance logging and error handling across various use cases. Introduced logDebugInfo for detailed execution tracing, added logWarn for non-critical warnings, and improved error messages for better context. Updated tests to mock new logging functions, ensuring comprehensive coverage of logging behavior.
…Enhance logging in mainRun function for GitHub Action and CLI. Added detailed log messages for execution events, setup completion, and action handling, improving traceability and debugging. Removed unused truncate function and adjusted error handling for JSON parsing to log full response text for better context.
…Update pull request description template to clarify output format requirements. Removed unnecessary preamble and commentary instructions, ensuring a more concise and structured output for PR descriptions.
…Update pull request description template in CLI and GitHub Action to streamline output format. Clarified instructions to eliminate preamble and commentary, ensuring a more direct and structured presentation of PR descriptions.
…Enhance logging functionality by introducing a sanitizeLogMessage function to remove markdown code fences from log messages. This ensures log output remains clear and unbroken when visualized in environments like GitHub Actions. Updated logInfo, logWarn, logError, and logDebugInfo functions to utilize the new sanitization method. Added tests to verify that markdown code fences are stripped from log messages.
| if (execution.isSingleAction && execution.singleAction.validSingleAction) { | ||
| logInfo(`User from token (${execution.tokenUser}) matches actor. Executing single action.`); | ||
| logInfo(`User from token (${execution.tokenUser}) matches actor. Executing single action: ${execution.singleAction.currentSingleAction}.`); | ||
| results.push(...await new SingleActionUseCase().invoke(execution)); |
There was a problem hiding this comment.
Log clearing occurs after setup, missing setup logs
Severity: low
Location: src/actions/common_action.ts:40
In mainRun(), clearAccumulatedLogs() is called after execution.setup() completes (line 40). If setup() logs any entries, those logs will not be cleared and will persist. Additionally, if setup() throws an exception, clearAccumulatedLogs() is never called, potentially leaking logs from a previous run into error handling contexts.
Suggested fix:
Move clearAccumulatedLogs() to the very beginning of mainRun(), before any other operations including execution.setup().
Written by vypdev/copilot for commit 06fb6072fde0f7de43f4fa6867b17015a56e1431. This will update automatically on new commits.
🐛 Bugfix Actions
Debug log🚀 Happy coding! Made with ❤️ by vypdev/copilot |


📌 Summary
Fixes an issue where the release branch merge to develop fails after a successful deployment. The problem occurred because after merging the release branch into the default branch (main/master), attempting to merge the release branch directly into develop could fail. The fix changes the second merge operation to use the default branch as the source instead of the release branch, following the same pattern used for hotfix branches.
🎯 Related Issues / Tickets
🧩 Scope of Changes
deployed_action_use_case.tsto merge default branch into develop (instead of release branch into develop) after the initial release-to-default mergedeployed_action_use_case.test.tsto match the corrected merge behavior🛠️ Technical Details
The issue occurred in the
DeployedActionUseCasewhen handling release branch deployments:Before (buggy):
After (fixed):
The hotfix branch flow already used this correct pattern (hotfix→main, then main→develop). The release flow has been updated to match, ensuring that after the release is merged into main, the updated main branch (which now contains all release changes) is merged into develop. This prevents merge failures that could occur when trying to merge the release branch directly into develop after it had already been merged into main.
🔍 How to Test
deploylabel to trigger the release workflowdeployedsingle action🧪 Test Coverage
🚀 Deployment Notes
🔒 Security Considerations
📈 Performance Impact
📝 Notes for Reviewers
The key change is in line 100 of
deployed_action_use_case.tswhere the second merge operation for release branches now usesparam.branches.defaultBranchinstead ofparam.currentConfiguration.releaseBranchas the head parameter. This aligns the release branch behavior with the hotfix branch behavior, which was already correct.✅ Checklist
📚 Additional Context
The error message "Issue #ANY_ISSUE_NUM was not closed because one or more merge operations failed" was appearing even when all PR checks passed because the second merge operation (release→develop) was attempting to merge a branch that had already been merged into main, potentially causing conflicts or fast-forward issues. By merging main→develop instead, we ensure a clean merge path.