-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shared repository Variable duplicate fix, Re run Failed fix and Edge … #3976
Conversation
…browser profile and selenium arguments fix
WalkthroughThis pull request introduces modifications to several classes within the Changes
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (5)
Ginger/GingerCoreNET/Repository/SharedRepositoryOperations.cs (3)
107-107
: Remove unnecessary empty line.This empty line doesn't serve any purpose and affects code readability.
-
Line range hint
607-626
: Consider optimizing GUID updates for large activities.The current implementation using LINQ's
Any
andFirst
inside a loop could be inefficient for activities with many actions and flow controls. Consider using a Dictionary for O(1) lookup:- List<KeyValuePair<Guid, Guid>> oldNewActionGuidList = []; + Dictionary<Guid, Guid> guidMapping = new(); foreach (Act action in sharedActivity.Acts.Cast<Act>()) { if (action.ParentGuid != Guid.Empty) { - oldNewActionGuidList.Add(new(action.Guid, action.ParentGuid)); + guidMapping[action.Guid] = action.ParentGuid; action.Guid = action.ParentGuid; } action.ParentGuid = Guid.Empty; } foreach (FlowControl fc in sharedActivity.Acts.SelectMany(a => a.FlowControls)) { Guid targetGuid = fc.GetGuidFromValue(); - if (oldNewActionGuidList.Any(oldNew => oldNew.Key == targetGuid)) + if (guidMapping.TryGetValue(targetGuid, out Guid newTargetGuid)) { - Guid newTargetGuid = oldNewActionGuidList.First(oldNew => oldNew.Key == targetGuid).Value; fc.Value = fc.Value.Replace(targetGuid.ToString(), newTargetGuid.ToString()); } }
Line range hint
607-626
: Add documentation for GUID management logic.The GUID management logic is complex and critical for maintaining proper relationships. Consider adding XML documentation to explain:
- The purpose of GUID updates
- The relationship between action GUIDs and their parents
- The flow control GUID update process
+ /// <summary> + /// Updates GUIDs for actions in a shared activity: + /// 1. Replaces action GUIDs with their parent GUIDs + /// 2. Clears ParentGuid references + /// 3. Updates flow control references to maintain consistency + /// </summary> List<KeyValuePair<Guid, Guid>> oldNewActionGuidList = [];Ginger/GingerCoreNET/RunLib/CLILib/CLIHelper.cs (1)
Based on the complete context, I can now generate the final response:
API calls need consistent error handling and null safety improvements
The code has several issues with API response handling:
- No try-catch blocks around API calls to handle potential network or server errors
- Inconsistent null/empty checks across different API responses:
GetRunsetExecutionDataFromCentralDB
: Has both null and count checkGetRunnerExecutionDataFromCentralDB
: Only has null checkGetBusinessflowExecutionDataFromCentralDB
: Has both null and count check- No validation of the status values before accessing them
- Direct string comparison for status without enum parsing validation
🔗 Analysis chain
Line range hint
354-424
: Consider adding null checks and error handling for API responses.The code assumes that the API responses will always have valid status values. It's recommended to add proper null checks and error handling.
Consider implementing a response validation helper method to ensure consistent error handling across all API responses:
private bool ValidateApiResponse<T>(IEnumerable<T> response, string context) where T : class { if (response == null || !response.Any()) { Reporter.ToLog(eLogLevel.INFO, $"No {context} records found for reference execution id: {mRunSetConfig.ReRunConfigurations.ReferenceExecutionID}"); return false; } return true; }
Let me analyze the API response handling patterns shown in the search results.
I can see that:
- For
GetRunsetExecutionDataFromCentralDB
- There's a null check and count check- For
GetRunnerExecutionDataFromCentralDB
- There's only a null check- For
GetBusinessflowExecutionDataFromCentralDB
- There's a null check and count checkLet me verify if there's any try-catch error handling around these API calls.
Let me try a different approach to check for error handling patterns around these API calls.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for similar API response handling patterns in the codebase rg -A 5 "accountReportApiHandler\.Get.*FromCentralDB"Length of output: 2845
Script:
#!/bin/bash # Search for try-catch blocks around the API calls rg -B 5 -A 10 "try.*\{.*accountReportApiHandler\.Get.*FromCentralDB"Length of output: 70
Script:
#!/bin/bash # Search for the broader context around these API calls to understand error handling rg -B 10 -A 10 "accountReportApiHandler\.Get.*FromCentralDB" --context-separator="---"Length of output: 7431
Ginger/GingerCoreCommon/Repository/BusinessFlowLib/Activity.cs (1)
Based on the search results, I can now make a determination. The code shows:
- Variables are actively used and tracked in the Activity class with proper parent-child relationships
- In CopySharedRepositoryActivity, the code updates ParentGuid for actions but previously had variable ParentGuid updates that were removed
- The GingerExecutionEngine and DynamicExecutionManager (from earlier search) rely on variable ParentGuid for lookups
Warning: Removing variable ParentGuid updates could break variable tracking.
The removal of variable parent GUID updates while keeping action parent GUID updates creates an inconsistency in the shared repository activity copy process. This could lead to:
- Broken variable lookups during execution
- Issues with variable relationship tracking
- Problems with dynamic execution variable mapping
🔗 Analysis chain
Line range hint
932-940
: LGTM! The FlowControl GUID update logic looks correct.The code properly updates FlowControl target GUIDs by:
- Collecting all FlowControls across all actions
- Checking if their target GUIDs exist in the oldNewActionGuidList
- Replacing old GUIDs with new ones in the FlowControl value
However, let's verify that removing the variable parent GUID updates doesn't cause issues elsewhere.
Let me analyze the results from the executed scripts. The search results show:
- The
Variables.*ParentGuid
usage appears primarily in test resources and configuration files, not in actual implementation code.- Most occurrences are in HTML report configurations and test data, where ParentGuid is used for reference tracking.
- The only implementation-related references are in:
- GingerExecutionEngine.cs - for variable lookup during execution
- DynamicExecutionManager.cs - for customized variable handling
The search results indicate that variable ParentGuid is still actively used in the codebase for variable tracking and relationship management. Removing the variable parent GUID updates could break this functionality.
Let me verify the specific variable handling in the Activity class to make a final determination.
Let me try a different search pattern to find the variable handling code.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for any code that depends on Activity Variables ParentGuid # Test: Search for variable parent GUID usage rg -A 3 "Variables.*ParentGuid" # Test: Search for potential variable relationship handling ast-grep --pattern 'class $_ { $$$ Variables { $$$ ParentGuid $$$ } $$$ }'Length of output: 75094
Script:
#!/bin/bash # Check Activity class implementation for variable handling ast-grep --pattern 'class Activity { $$$ CopyInstance($_) { $$$ } $$$ }' # Search for variable-related code in Activity rg -A 3 "Variables.*Copy" Ginger/GingerCoreCommon/Repository/BusinessFlowLib/Activity.csLength of output: 6111
Script:
#!/bin/bash # Search for variable handling in Activity.cs rg -A 5 "CopySharedRepositoryActivity" Ginger/GingerCoreCommon/Repository/BusinessFlowLib/Activity.cs # Search for variable-related code in Activity.cs rg -A 5 "Variables\." Ginger/GingerCoreCommon/Repository/BusinessFlowLib/Activity.cs # Look for variable parent updates rg -A 5 "\.ParentGuid\s*=" Ginger/GingerCoreCommon/Repository/BusinessFlowLib/Activity.csLength of output: 6620
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
- Ginger/GingerCoreCommon/Repository/BusinessFlowLib/Activity.cs (1 hunks)
- Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (1 hunks)
- Ginger/GingerCoreNET/Repository/SharedRepositoryOperations.cs (1 hunks)
- Ginger/GingerCoreNET/RunLib/CLILib/CLIHelper.cs (3 hunks)
🧰 Additional context used
📓 Learnings (1)
Ginger/GingerCoreCommon/Repository/BusinessFlowLib/Activity.cs (3)
Learnt from: Maheshkale447 PR: Ginger-Automation/Ginger#3918 File: Ginger/GingerCoreCommon/Repository/BusinessFlowLib/Activity.cs:1271-1287 Timestamp: 2024-10-09T01:33:39.965Z Learning: Prefers the original implementation of the `VariablesSummary` property using explicit list creation over LINQ for better readability.
Learnt from: Maheshkale447 PR: Ginger-Automation/Ginger#3918 File: Ginger/GingerCoreCommon/Repository/BusinessFlowLib/Activity.cs:1271-1287 Timestamp: 2024-10-09T01:33:41.350Z Learning: Prefers the original implementation of the `VariablesSummary` property using explicit list creation over LINQ for better readability.
Learnt from: Maheshkale447 PR: Ginger-Automation/Ginger#3918 File: Ginger/GingerCoreCommon/Repository/BusinessFlowLib/Activity.cs:1271-1287 Timestamp: 2024-09-22T17:01:36.055Z Learning: Prefers the original implementation of the `VariablesSummary` property using explicit list creation over LINQ for better readability.
🔇 Additional comments (3)
Ginger/GingerCoreNET/Repository/SharedRepositoryOperations.cs (1)
Line range hint
607-626
: Consider adding error handling for edge cases.While the GUID management logic is correct, consider adding error handling for scenarios where:
- Action GUIDs are duplicated
- Flow control target GUIDs are invalid
- ParentGuid references are circular
This will improve the robustness of the code.
Let's verify if there are any existing error cases:
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (2)
806-806
: Proper handling of UserProfileFolderPath for Edge browserThe addition of the
--user-data-dir
argument toEdgeOptions
whenUserProfileFolderPath
is valid ensures that Edge uses the specified user data directory. This mirrors the behavior implemented for other browsers and promotes consistency.
812-818
: Consistent addition of Selenium user arguments for Edge browserThe loop correctly adds
SeleniumUserArgs
toEdgeOptions
, aligning the Edge browser configuration with the implementations for Chrome and Brave browsers. This enhances flexibility by allowing user-defined arguments to be passed to the Edge browser.
…browser profile and selenium arguments fix
Thank you for your contribution.
Before submitting this PR, please make sure:
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Style