Trailing spaces/ white spaces issues were there in HTMLReportServiceU…#4295
Conversation
WalkthroughConvert GenerateHTMLReport to a static API on GingerRemoteExecutionUtils, add GetOnlineHTMLReportlink, null-safe URL trimming, and wrap Process.Start in try/catch with improved error messages; update callers to invoke the static method. No other control-flow changes. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User as User
participant UI as Run / RunSet Pages
participant Utils as GingerRemoteExecutionUtils
participant Config as Config/Settings
participant OS as OS Process Launcher
User->>UI: Request HTML report for executionGuid
UI->>Utils: GenerateHTMLReport(executionGuid) [static]
Utils->>Config: GetHTMLReportServiceUrl()?.Trim()
alt Service URL available
Utils->>Utils: Build report URL (local var)
Utils->>OS: Process.Start(reportUrl)
alt Launch succeeds
OS-->>Utils: OK
Utils-->>UI: return
else Launch fails
OS-->>Utils: Exception
Utils-->>UI: Show error with URL + exception
end
else No service URL
Utils-->>UI: Show "Centralized HTML Report Service URL is missing in Configurations > Reports > Execution Logger. Please configure the HTML Report URL." message
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (3)📓 Common learnings📚 Learning: 2024-09-16T16:34:20.667ZApplied to files:
📚 Learning: 2024-06-12T12:54:44.221ZApplied to files:
🧬 Code graph analysis (1)Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs (2)
🔇 Additional comments (3)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs (1)
164-178: Nice: trimming the configured base URL. Consider normalizing the trailing delimiters to avoid odd endings.Current logic is fine. As a minor hardening, normalize “/#/” once to prevent accidental “//#/” or “/#/#/” endings when admins tweak configs.
- if (!string.IsNullOrEmpty(baseURI)) - { - if (!baseURI.EndsWith("/")) - { - baseURI += "/"; - } - if (!baseURI.EndsWith("#/")) - { - baseURI += "#/"; - } - } + if (!string.IsNullOrEmpty(baseURI)) + { + baseURI = baseURI.TrimEnd(); + // Ensure single trailing '/#/': + baseURI = baseURI.TrimEnd('/'); + if (baseURI.EndsWith("#")) + { + baseURI = baseURI.TrimEnd('#'); + } + baseURI += "/#/"; + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
Ginger/Ginger/Run/RunSetsExecutionsHistoryPage.xaml.cs(1 hunks)Ginger/Ginger/RunSetPageLib/NewRunSetPage.xaml.cs(1 hunks)Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs(2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#3909
File: Ginger/Ginger/RunSetPageLib/NewRunSetPage.xaml.cs:2328-2346
Timestamp: 2024-09-16T16:34:20.667Z
Learning: In `NewRunSetPage.xaml.cs`, the methods `GenerateHTMLReportFromRemote()` and `GenerateHTMLReportFromLocal()` are kept separate because the application first tries to load remote data, and if not found, it falls back to loading local data.
📚 Learning: 2024-09-16T16:34:20.667Z
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#3909
File: Ginger/Ginger/RunSetPageLib/NewRunSetPage.xaml.cs:2328-2346
Timestamp: 2024-09-16T16:34:20.667Z
Learning: In `NewRunSetPage.xaml.cs`, the methods `GenerateHTMLReportFromRemote()` and `GenerateHTMLReportFromLocal()` are kept separate because the application first tries to load remote data, and if not found, it falls back to loading local data.
Applied to files:
Ginger/Ginger/RunSetPageLib/NewRunSetPage.xaml.csGinger/Ginger/Run/RunSetsExecutionsHistoryPage.xaml.csGinger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs
🧬 Code graph analysis (1)
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs (2)
Ginger/GingerCoreCommon/ReporterLib/Reporter.cs (1)
Reporter(28-357)Ginger/GingerCoreNET/External/GingerPlay/GingerPlayEndPointManager.cs (2)
GingerPlayEndPointManager(27-255)GetHTMLReportServiceUrl(107-139)
🔇 Additional comments (3)
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs (1)
133-134: All GenerateHTMLReport calls are now static
No remaining instance-based calls toGenerateHTMLReportwere found.Ginger/Ginger/RunSetPageLib/NewRunSetPage.xaml.cs (1)
2347-2354: LGTM: switched to static GenerateHTMLReport.Call site now matches the static API.
Ginger/Ginger/Run/RunSetsExecutionsHistoryPage.xaml.cs (1)
872-882: LGTM: remote report action uses the static GenerateHTMLReport.Consistent with the new API.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs (1)
182-194: Validate Guid? and encode; consider naming consistency.
- If null is allowed, return early with a log to avoid “?ExecutionId=” URLs.
- Encode the value.
- Optional: rename to GetOnlineHTMLReportLink (PascalCase “Link”) for consistency.
- public static string GetOnlineHTMLReportlink(Guid? executionGuid) + public static string GetOnlineHTMLReportlink(Guid? executionGuid) { var htmlServiceUrl = GetReportHTMLServiceUrl(); if (!string.IsNullOrEmpty(htmlServiceUrl)) { - return htmlServiceUrl + "?ExecutionId=" + executionGuid; + if (!executionGuid.HasValue) + { + Reporter.ToLog(eLogLevel.ERROR, "Execution ID is missing; cannot build online HTML report link."); + return string.Empty; + } + return $"{htmlServiceUrl}?ExecutionId={Uri.EscapeDataString(executionGuid.Value.ToString())}"; } else { Reporter.ToLog(eLogLevel.ERROR, "Centralized Html Report Service URL is missing in General Report Configurations.\nPlease go to Configurations > Reports > Execution Logger Configurations to configure the HTML Report URL"); return string.Empty; } }If you’d like to align naming now, consider:
- public static string GetOnlineHTMLReportLink(Guid executionGuid)
- public static void GenerateHTMLReport(Guid executionGuid)
♻️ Duplicate comments (1)
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs (1)
138-146: Encode ExecutionId when constructing the URL.Reiterating earlier feedback: encode the query value to avoid whitespace and special-char issues in the final URL.
- string url = htmlServiceUrl + "?ExecutionId=" + executionGuid; + // ExecutionId is not expected to be null here; encode to be safe against stray spaces/special chars + string url = $"{htmlServiceUrl}?ExecutionId={Uri.EscapeDataString(executionGuid.Trim())}";
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs(2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#3909
File: Ginger/Ginger/RunSetPageLib/NewRunSetPage.xaml.cs:2328-2346
Timestamp: 2024-09-16T16:34:20.667Z
Learning: In `NewRunSetPage.xaml.cs`, the methods `GenerateHTMLReportFromRemote()` and `GenerateHTMLReportFromLocal()` are kept separate because the application first tries to load remote data, and if not found, it falls back to loading local data.
📚 Learning: 2024-09-16T16:34:20.667Z
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#3909
File: Ginger/Ginger/RunSetPageLib/NewRunSetPage.xaml.cs:2328-2346
Timestamp: 2024-09-16T16:34:20.667Z
Learning: In `NewRunSetPage.xaml.cs`, the methods `GenerateHTMLReportFromRemote()` and `GenerateHTMLReportFromLocal()` are kept separate because the application first tries to load remote data, and if not found, it falls back to loading local data.
Applied to files:
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs
📚 Learning: 2024-06-12T12:54:44.221Z
Learnt from: IamRanjeetSingh
PR: Ginger-Automation/Ginger#3753
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserTab.cs:99-99
Timestamp: 2024-06-12T12:54:44.221Z
Learning: User IamRanjeetSingh prefers exceptions to propagate rather than being caught and handled locally within methods in `PlaywrightBrowserTab.cs`.
Applied to files:
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs
🧬 Code graph analysis (1)
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs (2)
Ginger/GingerCoreCommon/ReporterLib/Reporter.cs (1)
Reporter(28-357)Ginger/GingerCoreNET/External/GingerPlay/GingerPlayEndPointManager.cs (2)
GingerPlayEndPointManager(27-255)GetHTMLReportServiceUrl(107-139)
🔇 Additional comments (2)
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs (2)
148-153: Good: failure path now logs details.The additional ToLog with the exception is the right call for observability.
165-179: The verification script is running; I’ll review the output next.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs (1)
181-193: Rename method, add null-check, update call sites
- In Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs, rename GetOnlineHTMLReportlink to GetOnlineHTMLReportLink, guard against executionGuid == null (log error, return empty), escape the GUID, and update error message to “HTML”
- Update all calls—e.g. in RunSetActionHTMLReportSendEmailOperations.cs (line 305), change to GetOnlineHTMLReportLink(...)
♻️ Duplicate comments (1)
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs (1)
133-146: Build the URL safely: trim/encode executionGuid and validate URL before launching.Avoid raw concatenation; guard against accidental spaces and malformed URLs. Also ensure only http/https schemes are launched.
- string url = htmlServiceUrl + "?ExecutionId=" + executionGuid; + var id = executionGuid?.Trim(); + if (string.IsNullOrWhiteSpace(id)) + { + Reporter.ToUser(eUserMsgKey.StaticErrorMessage, "Execution ID is missing."); + return; + } + string url = $"{htmlServiceUrl}?ExecutionId={Uri.EscapeDataString(id)}"; + if (!Uri.TryCreate(url, UriKind.Absolute, out var uri) || + (uri.Scheme != Uri.UriSchemeHttp && uri.Scheme != Uri.UriSchemeHttps)) + { + Reporter.ToUser(eUserMsgKey.StaticErrorMessage, $"Invalid report URL.\nURL: {url}"); + Reporter.ToLog(eLogLevel.ERROR, $"Invalid HTML report URL: {url}"); + return; + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs(2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#3909
File: Ginger/Ginger/RunSetPageLib/NewRunSetPage.xaml.cs:2328-2346
Timestamp: 2024-09-16T16:34:20.667Z
Learning: In `NewRunSetPage.xaml.cs`, the methods `GenerateHTMLReportFromRemote()` and `GenerateHTMLReportFromLocal()` are kept separate because the application first tries to load remote data, and if not found, it falls back to loading local data.
📚 Learning: 2024-09-16T16:34:20.667Z
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#3909
File: Ginger/Ginger/RunSetPageLib/NewRunSetPage.xaml.cs:2328-2346
Timestamp: 2024-09-16T16:34:20.667Z
Learning: In `NewRunSetPage.xaml.cs`, the methods `GenerateHTMLReportFromRemote()` and `GenerateHTMLReportFromLocal()` are kept separate because the application first tries to load remote data, and if not found, it falls back to loading local data.
Applied to files:
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs
📚 Learning: 2024-06-12T12:54:44.221Z
Learnt from: IamRanjeetSingh
PR: Ginger-Automation/Ginger#3753
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserTab.cs:99-99
Timestamp: 2024-06-12T12:54:44.221Z
Learning: User IamRanjeetSingh prefers exceptions to propagate rather than being caught and handled locally within methods in `PlaywrightBrowserTab.cs`.
Applied to files:
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs
🧬 Code graph analysis (1)
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs (2)
Ginger/GingerCoreCommon/ReporterLib/Reporter.cs (1)
Reporter(28-357)Ginger/GingerCoreNET/External/GingerPlay/GingerPlayEndPointManager.cs (2)
GingerPlayEndPointManager(27-255)GetHTMLReportServiceUrl(107-139)
🔇 Additional comments (3)
Ginger/GingerCoreNET/Run/GingerRemoteExecutionUtils.cs (3)
148-153: Good: user-facing error plus log on failure.Catching and both surfacing to user and logging exception details improves diagnostics.
164-177: Nice: null-safe trim and normalized suffix.Using
?.Trim()and ensuring/#/normalization addresses trailing/leading whitespace issues.
133-133: Static API change is safe—no remaining instance callers. Verified that all GenerateHTMLReport invocations in RunSetsExecutionsHistoryPage.xaml.cs and NewRunSetPage.xaml.cs use the static method and nonew GingerRemoteExecutionUtils()calls exist.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…RL() fixed
Thank you for your contribution.
Before submitting this PR, please make sure:
Summary by CodeRabbit
Refactor
Bug Fixes
Style