Runner name added in Source Path#4340
Conversation
WalkthroughExecutionLoggerManager.cs modified to enhance ActionEnd logging with expanded context. SourcePath construction changed from ">" separators to "->" separators while incorporating GingerRunner name. ParentActivityID field added to log output. Log call now properly formats and passes the enhanced SourcePath. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
Ginger/GingerCoreNET/Run/RunListenerLib/ExecutionLoggerManager.cs(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
Ginger/GingerCoreNET/Run/RunListenerLib/ExecutionLoggerManager.cs (2)
Ginger/GingerCoreNET/WorkSpaceLib/WorkSpace.cs (1)
WorkSpace(61-1006)Ginger/GingerCoreCommon/Run/GingerRunner.cs (1)
GingerRunner(53-317)
| string SourcePath = $"{WorkSpace.Instance?.RunsetExecutor?.RunSetConfig?.Name ?? "N/A"} -> {((GingerExecutionEngine)mContext?.Runner).GingerRunner.Name ?? "N/A"} -> {mContext?.BusinessFlow?.Name ?? "N/A"} -> {mCurrentActivity?.ActivityName ?? "N/A"} -> {(action?.ItemName ?? action?.Description ?? "N/A")}"; | ||
| ExecutionProgressReporterListener.AddExecutionDetailsToLog(ExecutionProgressReporterListener.eExecutionPhase.End, "Action", string.Format("{0} (ID:{1}, ParentID:{2}, ParentActivityID: {3})", action.Description, action.Guid, action.ExecutionParentGuid, mCurrentActivity?.Guid), AR,SourcePath); |
There was a problem hiding this comment.
Fix null-safety issue in SourcePath construction to prevent NullReferenceException.
The SourcePath construction has a critical null-safety flaw. When mContext?.Runner is null, the expression ((GingerExecutionEngine)mContext?.Runner).GingerRunner.Name attempts to access .GingerRunner.Name on a null reference, which will throw a NullReferenceException. Additionally, the cast to GingerExecutionEngine could throw an InvalidCastException if the Runner is not of that type.
Apply this diff to fix the null-safety issue:
- string SourcePath = $"{WorkSpace.Instance?.RunsetExecutor?.RunSetConfig?.Name ?? "N/A"} -> {((GingerExecutionEngine)mContext?.Runner).GingerRunner.Name ?? "N/A"} -> {mContext?.BusinessFlow?.Name ?? "N/A"} -> {mCurrentActivity?.ActivityName ?? "N/A"} -> {(action?.ItemName ?? action?.Description ?? "N/A")}";
+ string SourcePath = $"{WorkSpace.Instance?.RunsetExecutor?.RunSetConfig?.Name ?? "N/A"} -> {((GingerExecutionEngine)mContext?.Runner)?.GingerRunner?.Name ?? "N/A"} -> {mContext?.BusinessFlow?.Name ?? "N/A"} -> {mCurrentActivity?.ActivityName ?? "N/A"} -> {(action?.ItemName ?? action?.Description ?? "N/A")}";Alternatively, for better readability and safer type handling, consider extracting the GingerRunner name:
+ string runnerName = "N/A";
+ if (mContext?.Runner is GingerExecutionEngine gingerEngine)
+ {
+ runnerName = gingerEngine.GingerRunner?.Name ?? "N/A";
+ }
- string SourcePath = $"{WorkSpace.Instance?.RunsetExecutor?.RunSetConfig?.Name ?? "N/A"} -> {((GingerExecutionEngine)mContext?.Runner).GingerRunner.Name ?? "N/A"} -> {mContext?.BusinessFlow?.Name ?? "N/A"} -> {mCurrentActivity?.ActivityName ?? "N/A"} -> {(action?.ItemName ?? action?.Description ?? "N/A")}";
+ string SourcePath = $"{WorkSpace.Instance?.RunsetExecutor?.RunSetConfig?.Name ?? "N/A"} -> {runnerName} -> {mContext?.BusinessFlow?.Name ?? "N/A"} -> {mCurrentActivity?.ActivityName ?? "N/A"} -> {(action?.ItemName ?? action?.Description ?? "N/A")}";
ExecutionProgressReporterListener.AddExecutionDetailsToLog(ExecutionProgressReporterListener.eExecutionPhase.End, "Action", string.Format("{0} (ID:{1}, ParentID:{2}, ParentActivityID: {3})", action.Description, action.Guid, action.ExecutionParentGuid, mCurrentActivity?.Guid), AR, SourcePath);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| string SourcePath = $"{WorkSpace.Instance?.RunsetExecutor?.RunSetConfig?.Name ?? "N/A"} -> {((GingerExecutionEngine)mContext?.Runner).GingerRunner.Name ?? "N/A"} -> {mContext?.BusinessFlow?.Name ?? "N/A"} -> {mCurrentActivity?.ActivityName ?? "N/A"} -> {(action?.ItemName ?? action?.Description ?? "N/A")}"; | |
| ExecutionProgressReporterListener.AddExecutionDetailsToLog(ExecutionProgressReporterListener.eExecutionPhase.End, "Action", string.Format("{0} (ID:{1}, ParentID:{2}, ParentActivityID: {3})", action.Description, action.Guid, action.ExecutionParentGuid, mCurrentActivity?.Guid), AR,SourcePath); | |
| string SourcePath = $"{WorkSpace.Instance?.RunsetExecutor?.RunSetConfig?.Name ?? "N/A"} -> {((GingerExecutionEngine)mContext?.Runner)?.GingerRunner?.Name ?? "N/A"} -> {mContext?.BusinessFlow?.Name ?? "N/A"} -> {mCurrentActivity?.ActivityName ?? "N/A"} -> {(action?.ItemName ?? action?.Description ?? "N/A")}"; | |
| ExecutionProgressReporterListener.AddExecutionDetailsToLog(ExecutionProgressReporterListener.eExecutionPhase.End, "Action", string.Format("{0} (ID:{1}, ParentID:{2}, ParentActivityID: {3})", action.Description, action.Guid, action.ExecutionParentGuid, mCurrentActivity?.Guid), AR,SourcePath); |
| string SourcePath = $"{WorkSpace.Instance?.RunsetExecutor?.RunSetConfig?.Name ?? "N/A"} -> {((GingerExecutionEngine)mContext?.Runner).GingerRunner.Name ?? "N/A"} -> {mContext?.BusinessFlow?.Name ?? "N/A"} -> {mCurrentActivity?.ActivityName ?? "N/A"} -> {(action?.ItemName ?? action?.Description ?? "N/A")}"; | |
| ExecutionProgressReporterListener.AddExecutionDetailsToLog(ExecutionProgressReporterListener.eExecutionPhase.End, "Action", string.Format("{0} (ID:{1}, ParentID:{2}, ParentActivityID: {3})", action.Description, action.Guid, action.ExecutionParentGuid, mCurrentActivity?.Guid), AR,SourcePath); | |
| string runnerName = "N/A"; | |
| if (mContext?.Runner is GingerExecutionEngine gingerEngine) | |
| { | |
| runnerName = gingerEngine.GingerRunner?.Name ?? "N/A"; | |
| } | |
| string SourcePath = $"{WorkSpace.Instance?.RunsetExecutor?.RunSetConfig?.Name ?? "N/A"} -> {runnerName} -> {mContext?.BusinessFlow?.Name ?? "N/A"} -> {mCurrentActivity?.ActivityName ?? "N/A"} -> {(action?.ItemName ?? action?.Description ?? "N/A")}"; | |
| ExecutionProgressReporterListener.AddExecutionDetailsToLog(ExecutionProgressReporterListener.eExecutionPhase.End, "Action", string.Format("{0} (ID:{1}, ParentID:{2}, ParentActivityID: {3})", action.Description, action.Guid, action.ExecutionParentGuid, mCurrentActivity?.Guid), AR, SourcePath); |
🤖 Prompt for AI Agents
In Ginger/GingerCoreNET/Run/RunListenerLib/ExecutionLoggerManager.cs around
lines 604-605, the SourcePath construction can throw NullReferenceException or
InvalidCastException when mContext?.Runner is null or not a
GingerExecutionEngine; fix by using a safe cast and null propagation: assign a
local variable like var engine = mContext?.Runner as GingerExecutionEngine; then
get the runnerName = engine?.GingerRunner?.Name ?? "N/A"; finally build
SourcePath substituting this runnerName and using null-coalescing (?? "N/A") for
other parts so no member access occurs on null values.
cc944e8
into
Releases/Official-Release
Thank you for your contribution.
Before submitting this PR, please make sure:
Summary by CodeRabbit