Skip to content

Updated Magic Net package and Account report APIs#4293

Merged
Maheshkale447 merged 11 commits into
Releases/Betafrom
Fetaure/VersionMismatch
Sep 5, 2025
Merged

Updated Magic Net package and Account report APIs#4293
Maheshkale447 merged 11 commits into
Releases/Betafrom
Fetaure/VersionMismatch

Conversation

@Maheshkale447

@Maheshkale447 Maheshkale447 commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

Thank you for your contribution.
Before submitting this PR, please make sure:

  • PR description and commit message should describe the changes done in this PR
  • Verify the PR is pointing to correct branch i.e. Release or Beta branch if the code fix is for specific release , else point it to master
  • Latest Code from master or specific release branch is merged to your branch
  • No unwanted\commented\junk code is included
  • No new warning upon build solution
  • Code Summary\Comments are added to my code which explains what my code is doing
  • Existing unit test cases are passed
  • New Unit tests are added for your development
  • Sanity Tests are successfully executed for New and Existing Functionality
  • Verify that changes are compatible with all relevant browsers and platforms.
  • After creating pull request there should not be any conflicts
  • Resolve all Codacy comments
  • Builds and checks are passed before PR is sent for review
  • Resolve code review comments
  • Update the Help Library document to match any feature changes

Summary by CodeRabbit

  • Refactor

    • Execution-data submission now requires RunSet data to be confirmed sent before related runner/businessflow/activity/artifact/screenshot uploads proceed.
    • Report retrieval switched to the HTML Reports service for execution validation, businessflow, runset, runner, and HTML report fetch.
  • Chores

    • Upgraded image-processing dependency to Magick.NET-Q16-AnyCPU v14.8.2 across app, core, and test projects.
    • Updated visual-diff processing to use the newer image-processing API.
  • Misc

    • Improved upload reliability and clearer failure messages.

@coderabbitai

coderabbitai Bot commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Updated ImageMagick package references to 14.8.2 in three projects, adapted ImageMagick Compare calls to the new overload returning an IMagickImage and out percentage, and changed AccountReport API route constants to HtmlReport with a volatile _isRunSetDataSent flag gating subsequent send operations.

Changes

Cohort / File(s) Summary of changes
Dependency upgrades
Ginger/Ginger/Ginger.csproj, Ginger/GingerCoreNET/GingerCoreNET.csproj, Ginger/GingerTest/GingerTest.csproj
Bumped <PackageReference Include="Magick.NET-Q16-AnyCPU" /> from 13.5.0 to 14.8.2.
Endpoint routing & runset gating
Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs
Switched several endpoint constants from /api/AccountReport/... to /api/HtmlReport/.... Added instance-level volatile _isRunSetDataSent flag (initialized true) and gating logic in SendRunsetExecutionDataToCentralDBAsync and subsequent Send* methods to early-return when runset data wasn't sent; updated related log messages, added public default constructor, and minor formatting/catch changes.
ImageMagick Compare API updates
Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/MagickAnalyzer.cs, Ginger/GingerTest/GeneralLib/VisualCompare.cs
Replaced pre-allocated MagickImage diff pattern with the new overload that returns an IMagickImage and outputs percentageDifference via an out parameter; changed diff variable types accordingly and preserved downstream scaling/rounding and diff handling (byte conversion, file save, result logic).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller
  participant ApiHandler as AccountReportApiHandler
  participant HtmlReport as HtmlReport API

  rect rgba(220,240,255,0.5)
    note over Caller,ApiHandler: Retrieval paths moved to HtmlReport endpoints
    Caller->>ApiHandler: Request validation / execution data
    ApiHandler->>HtmlReport: GET /api/HtmlReport/...
    HtmlReport-->>ApiHandler: 200 / error
    ApiHandler-->>Caller: Response
  end
Loading
sequenceDiagram
  autonumber
  participant Sender
  participant Handler as AccountReportApiHandler
  participant Central as Central DB/API

  rect rgba(240,230,220,0.45)
    note over Sender,Handler: RunSet send gated by _isRunSetDataSent
    Sender->>Handler: Send RunSet (publish start / update)
    alt publish start (non-update)
      Handler->>Handler: _isRunSetDataSent = true
    else update
      Handler->>Handler: if _isRunSetDataSent == false -> return
    end
    Handler->>Central: POST runset data
    Central-->>Handler: success / failure
    Handler->>Handler: set _isRunSetDataSent true/false accordingly
  end
Loading
sequenceDiagram
  autonumber
  participant Caller
  participant Magick as Magick.NET
  participant Processor

  Caller->>Magick: Compare(base, target, metric, Channels, out pct)
  Magick-->>Caller: returns diffImage (IMagickImage) + out pct
  Caller->>Processor: Convert diffImage -> bytes/bitmap, compute pct*100 and round
  Processor-->>Caller: Save diff file, return comparison result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • MeniKadosh1

Poem

I nibble at bytes and hop through the night,
Routes now point to HtmlReport's bright light.
Diffs come back as images and a percent,
RunSet waits guarded — then onward it's sent.
A rabbit applauds: tidy, small, and spry 🥕


📜 Recent 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.

📥 Commits

Reviewing files that changed from the base of the PR and between e98d075 and 3c16f31.

📒 Files selected for processing (1)
  • Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (13 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-05T10:50:57.651Z
Learnt from: Maheshkale447
PR: Ginger-Automation/Ginger#4293
File: Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs:56-60
Timestamp: 2025-09-05T10:50:57.651Z
Learning: In AccountReportApiHandler.cs, the _isRunSetDataSent flag is correctly initialized to true by default. This flag acts as a circuit breaker where true allows operations to proceed and false blocks downstream operations after a RunSet send failure. The optimistic default (true) is necessary to allow the initial RunSet send attempt.

Applied to files:

  • Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs
📚 Learning: 2025-09-05T10:53:38.131Z
Learnt from: Maheshkale447
PR: Ginger-Automation/Ginger#4293
File: Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs:0-0
Timestamp: 2025-09-05T10:53:38.131Z
Learning: In AccountReportApiHandler.cs, the user confirmed that the _isRunSetDataSent flag follows a "fail first" circuit breaker pattern where it starts optimistically as true to allow initial operations, and only gets set to false after actual failures occur. This prevents unnecessary blocking before any failure has been detected.

Applied to files:

  • Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs
🧬 Code graph analysis (1)
Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (1)
Ginger/GingerCoreCommon/ReporterLib/Reporter.cs (1)
  • Reporter (28-357)
🔇 Additional comments (7)
Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (7)

56-60: Gate design and visibility: LGTM.

Instance-scoped volatile flag with optimistic default aligns with the agreed fail-first circuit-breaker semantics.


81-81: Good fix: preserve exception context in logs.


127-127: Reset-on-start matches “fail-first” intent.


131-136: Early return on update when gate is closed: correct.


153-161: Set-on-success / clear-on-failure: correct gating.


174-175: Propagation gating across child senders is consistently enforced.

Also applies to: 198-199, 215-216, 240-241, 264-265


316-317: Gating applied to uploads/artifacts is consistent.

Also applies to: 357-358, 391-392, 439-440

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Fetaure/VersionMismatch

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (2)
Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (2)

273-299: Validation should fail closed: don’t return true on request failure.

Current logic returns true when the call errors, which could allow invalid execution IDs.

Use strict parse and fail closed:

-                    RestResponse response = restClient.Execute(restRequest);
-                    if (response.IsSuccessful)
-                    {
-                        Reporter.ToLog(eLogLevel.DEBUG, $"Successfully validated execution id {message}");
-                        return Convert.ToBoolean(response.Content);
-                    }
-                    else
-                    {
-                        Reporter.ToLog(eLogLevel.ERROR, $"Failed to validate {message} Response: {response.Content}");
-                    }
+                    RestResponse response = restClient.Execute(restRequest);
+                    if (response.IsSuccessful && bool.TryParse(response.Content, out var isValid))
+                    {
+                        Reporter.ToLog(eLogLevel.DEBUG, $"Successfully validated execution id {message}");
+                        return isValid;
+                    }
+                    Reporter.ToLog(eLogLevel.ERROR, $"Failed to validate {message} Response: {response.Content}");
                 }
                 catch (Exception ex)
                 {
                     Reporter.ToLog(eLogLevel.ERROR, $"Exception while validating execution id {message}", ex);
                 }
-                return true;
+                return false;

65-71: TLS disabled: RemoteCertificateValidationCallback always returns true.

This bypasses HTTPS validation and is a security risk. Only allow in dev via config or remove override.

Example hardening:

-                        RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true,
+                        // Use default validation; if you must allow insecure for dev, gate it behind a config flag.
+                        // RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => sslPolicyErrors == System.Net.Security.SslPolicyErrors.None,
📜 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.

📥 Commits

Reviewing files that changed from the base of the PR and between fd572e4 and 1921ee0.

📒 Files selected for processing (4)
  • Ginger/Ginger/Ginger.csproj (1 hunks)
  • Ginger/GingerCoreNET/GingerCoreNET.csproj (1 hunks)
  • Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (1 hunks)
  • Ginger/GingerTest/GingerTest.csproj (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-25T08:48:11.915Z
Learnt from: AmanPrasad43
PR: Ginger-Automation/Ginger#4281
File: Ginger/GingerCore/GingerCore.csproj:538-538
Timestamp: 2025-08-25T08:48:11.915Z
Learning: In the Ginger codebase, the OWASPZAPDotNetAPI package reference in GingerCore.csproj is required for architectural reasons, even when direct usage is not immediately visible in the codebase. This was confirmed by AmanPrasad43 during the security testing feature implementation.

Applied to files:

  • Ginger/GingerTest/GingerTest.csproj
🔇 Additional comments (4)
Ginger/Ginger/Ginger.csproj (1)

740-740: Magick.NET upgraded to 14.8.2 – confirm CI tests on both platforms

  • Verified no csproj still references 13.x (all three projects now use 14.8.2).
  • Run/confirm smoke tests on Windows and Linux runners to ensure native dependencies and APIs function as expected.
Ginger/GingerCoreNET/GingerCoreNET.csproj (1)

296-296: Magick.NET version alignment confirmed; run smoke tests.
No csproj references to 13.x remain—every project now uses 14.8.2. Please execute image-processing smoke tests to validate the upgrade.

Ginger/GingerTest/GingerTest.csproj (1)

23-23: Run tests to confirm compatibility with Magick.NET-Q16-AnyCPU 14.8.2
Replace the echo in the verification script with actual execution, for example:

fd -a GingerTest.csproj | xargs -I{} dotnet test "{}" -c Release --nologo

Ensure the tests pass locally and on CI.

Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (1)

50-55: Confirm backend routing parity between HtmlReport GET and AccountReport POST/PUT.

All GET calls now point to api/HtmlReport (AccountReportApiHandler.cs lines 50–55); no api/AccountReport GET references remain. Verify the server exposes these HtmlReport GET routes and returns identical models to the existing AccountReport POST/PUT endpoints.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (5)
Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/MagickAnalyzer.cs (2)

42-56: Dispose MagickImage/diff and avoid use-after-dispose on Bitmap.

  • MagickImage and the IMagickImage returned from Compare are IDisposable; not disposing them leaks native memory.
  • Inside the using block, ImgToSave is disposed, yet you assign and pass it (mAct.CompareResult, AddScreenShot). That creates a disposed reference risk.

Apply the refactor below to scope-dispose Magick images/diff and hand off live Bitmap instances to mAct:

-            MagickImage magickBaseImg = new MagickImage(General.ImageToByteArray(mAct.baseImage, System.Drawing.Imaging.ImageFormat.Bmp));//Not tested after code change
-            MagickImage magickTargetImg = new MagickImage(General.ImageToByteArray(mAct.targetImage, System.Drawing.Imaging.ImageFormat.Bmp));//Not tested after code change
-
-            double percentageDifference;
+            using (var magickBaseImg = new MagickImage(General.ImageToByteArray(mAct.baseImage, System.Drawing.Imaging.ImageFormat.Bmp))) // Not tested after code change
+            using (var magickTargetImg = new MagickImage(General.ImageToByteArray(mAct.targetImage, System.Drawing.Imaging.ImageFormat.Bmp))) // Not tested after code change
+            {
+                double percentageDifference;

-            ErrorMetric eErrorMetric = ErrorMetric.Fuzz;
-            Enum.TryParse<ErrorMetric>(mAct.GetOrCreateInputParam(ActVisualTesting.Fields.ErrorMetric).Value, out eErrorMetric);
-            IMagickImage diffImg = magickBaseImg.Compare(magickTargetImg, eErrorMetric, Channels.Red, out percentageDifference);
-            percentageDifference = percentageDifference * 100;
-            percentageDifference = Math.Round(percentageDifference, 2);
+                ErrorMetric eErrorMetric = ErrorMetric.Fuzz;
+                Enum.TryParse<ErrorMetric>(mAct.GetOrCreateInputParam(ActVisualTesting.Fields.ErrorMetric).Value, true, out eErrorMetric);
+                using (IMagickImage diffImg = magickBaseImg.Compare(magickTargetImg, eErrorMetric, Channels.Red, out percentageDifference))
+                {
+                    percentageDifference = Math.Round(percentageDifference * 100, 2);

-            TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
-            using (Bitmap ImgToSave = (Bitmap)tc.ConvertFrom(diffImg.ToByteArray()))
-            {
-                mAct.CompareResult = ImgToSave;//Not tested after code change
-
-                mAct.AddOrUpdateReturnParamActual("Percentage Difference", percentageDifference + "");
-
-                mAct.AddScreenShot(ImgToSave, "Compare Result");
-            }
+                    TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
+                    using (Bitmap imgToSave = (Bitmap)tc.ConvertFrom(diffImg.ToByteArray(MagickFormat.Png)))
+                    {
+                        // Hand off owned clones to mAct; keep local disposed.
+                        mAct.CompareResult = (Bitmap)imgToSave.Clone(); // Not tested after code change
+                        mAct.AddOrUpdateReturnParamActual("Percentage Difference", percentageDifference.ToString(System.Globalization.CultureInfo.InvariantCulture));
+                        mAct.AddScreenShot((Bitmap)imgToSave.Clone(), "Compare Result");
+                    }
+                }
+            }

55-62: Persist a live Bitmap; don’t assign a disposed instance.

If CompareResult or AddScreenShot retain the reference, the current using block disposes it prematurely.

Covered by the refactor above (clone before leaving the using block).

Ginger/GingerTest/GeneralLib/VisualCompare.cs (3)

107-121: Dispose MagickImage/diff and the Bitmap; specify a stable output format.

Avoid native leaks and ensure converter recognizes bytes by specifying MagickFormat.

-            MagickImage magickBaseImg = new MagickImage(BaseImageFileName);
-            MagickImage magickTargetImg = new MagickImage(TargetImageFileName);
+            using (var magickBaseImg = new MagickImage(BaseImageFileName))
+            using (var magickTargetImg = new MagickImage(TargetImageFileName))
+            {

-            double percentageDifference;
+            double percentageDifference;

             ErrorMetric EM = ErrorMetric.Fuzz;   // Fuzz !?
-            IMagickImage diffImg = magickBaseImg.Compare(magickTargetImg, EM, Channels.Red, out percentageDifference);
-            percentageDifference = percentageDifference * 100;
-            percentageDifference = Math.Round(percentageDifference, 2);
+            using (IMagickImage diffImg = magickBaseImg.Compare(magickTargetImg, EM, Channels.Red, out percentageDifference))
+            {
+                percentageDifference = Math.Round(percentageDifference * 100, 2);

-            TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
-            Bitmap ImgToSave = (Bitmap)tc.ConvertFrom(diffImg.ToByteArray());
-            ImgToSave.Save(ResultFileName);
+                TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
+                using (Bitmap imgToSave = (Bitmap)tc.ConvertFrom(diffImg.ToByteArray(MagickFormat.Png)))
+                {
+                    imgToSave.Save(ResultFileName);
+                }
+            }
+            }

122-129: Simplify boolean return.

Minor readability tweak.

-            if (percentageDifference == 0)
-            {
-                return true;
-            }
-            else
-            {
-                return false;
-            }
+            return percentageDifference == 0;

72-73: Typo in public method names (“Equel”). Consider adding correctly named wrappers.

Leaving old methods for back-compat; add new IsVisualEqual/IsBitmapEqual and mark old as [Obsolete].

I can draft the wrappers if you want this in the same PR.

Also applies to: 105-106

📜 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 1921ee0 and 1f5588a.

📒 Files selected for processing (2)
  • Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/MagickAnalyzer.cs (1 hunks)
  • Ginger/GingerTest/GeneralLib/VisualCompare.cs (1 hunks)
🔇 Additional comments (1)
Ginger/GingerTest/GeneralLib/VisualCompare.cs (1)

114-116: Channel selection sanity-check.

Using Channels.Red restricts comparison to the red channel. If unintended, switch to Channels.Composite/All or make it configurable.

Would you like me to parameterize the channel selection alongside ErrorMetric?

Comment thread Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/MagickAnalyzer.cs
Comment thread Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/MagickAnalyzer.cs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

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/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (1)

281-306: ExecutionIdValidation returns true on error paths — this defeats validation

On network error or non-success HTTP status, the method logs an error but returns true. That can allow invalid executions to pass checks and cascade failures later.

Apply:

@@ public bool ExecutionIdValidation(Guid executionId)
-                try
+                try
                 {
                     RestResponse response = restClient.Execute(restRequest);
                     if (response.IsSuccessful)
                     {
                         Reporter.ToLog(eLogLevel.DEBUG, $"Successfully validated execution id {message}");
                         return Convert.ToBoolean(response.Content);
                     }
                     else
                     {
                         Reporter.ToLog(eLogLevel.ERROR, $"Failed to validate {message} Response: {response.Content}");
-                    }
+                        return false;
+                    }
                 }
                 catch (Exception ex)
                 {
                     Reporter.ToLog(eLogLevel.ERROR, $"Exception while validating execution id {message}", ex);
-                }
-                return true;
+                    return false;
+                }
♻️ Duplicate comments (1)
Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (1)

50-54: Normalize HtmlReport GET endpoints; remove leading slash to avoid base-URL reset

All new GET constants look good, but GET_ACCOUNT_HTML_REPORT starts with “/” while others don’t. With RestSharp, a leading “/” can discard any base-path segment in the client’s BaseUrl, yielding wrong URLs. Align it with the others.

Apply:

-        private const string GET_ACCOUNT_HTML_REPORT = "/api/HtmlReport/GetAccountHtmlReport/";
+        private const string GET_ACCOUNT_HTML_REPORT = "api/HtmlReport/GetAccountHtmlReport/";

Verification (optional):

#!/bin/bash
# 1) Check for any remaining endpoint constants starting with a leading slash
rg -nP '^\s*private\s+const\s+string\s+\w+\s*=\s*"/api/' --type cs

# 2) Find any hard-coded "/api/HtmlReport" usages that may still bypass the base path
rg -nP '"/api/HtmlReport' --type cs
📜 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 1f5588a and ce887c3.

📒 Files selected for processing (1)
  • Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (12 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (1)
Ginger/GingerCoreCommon/ReporterLib/Reporter.cs (1)
  • Reporter (28-357)
🔇 Additional comments (1)
Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (1)

320-331: No fallback needed—GingerCoreNET.csproj uses <LangVersion>preview so collection expressions ([]) are supported

Likely an incorrect or invalid review comment.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/MagickAnalyzer.cs (2)

42-63: Dispose Magick.NET images and avoid assigning a disposed Bitmap (plus safer parsing and culture-stable output).

Unmanaged resources are leaked (MagickImage/IMagickImage not disposed). Also, mAct.CompareResult is set to a Bitmap that is disposed at the end of the using block, risking later ObjectDisposedException. Patch also trims/null-guards enum parsing and emits the percentage using invariant culture.

Apply this diff:

-            MagickImage magickBaseImg = new MagickImage(General.ImageToByteArray(mAct.baseImage, System.Drawing.Imaging.ImageFormat.Bmp));//Not tested after code change
-            MagickImage magickTargetImg = new MagickImage(General.ImageToByteArray(mAct.targetImage, System.Drawing.Imaging.ImageFormat.Bmp));//Not tested after code change
-
-            double percentageDifference;
-
-            ErrorMetric eErrorMetric = ErrorMetric.Fuzz;
-            Enum.TryParse<ErrorMetric>(mAct.GetOrCreateInputParam(ActVisualTesting.Fields.ErrorMetric).Value, true, out eErrorMetric);
-
-            IMagickImage diffImg = magickBaseImg.Compare(magickTargetImg, eErrorMetric, Channels.Red, out percentageDifference);
-            percentageDifference = percentageDifference * 100;
-            percentageDifference = Math.Round(percentageDifference, 2);
-
-            TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
-            using (Bitmap ImgToSave = (Bitmap)tc.ConvertFrom(diffImg.ToByteArray()))
-            {
-                mAct.CompareResult = ImgToSave;//Not tested after code change
-
-                mAct.AddOrUpdateReturnParamActual("Percentage Difference", percentageDifference + "");
-
-                mAct.AddScreenShot(ImgToSave, "Compare Result");
-            }
+            using (MagickImage magickBaseImg = new MagickImage(General.ImageToByteArray(mAct.baseImage, System.Drawing.Imaging.ImageFormat.Bmp)))
+            using (MagickImage magickTargetImg = new MagickImage(General.ImageToByteArray(mAct.targetImage, System.Drawing.Imaging.ImageFormat.Bmp)))
+            {
+                double percentageDifference;
+                ErrorMetric eErrorMetric = ErrorMetric.Fuzz;
+                Enum.TryParse<ErrorMetric>(mAct.GetOrCreateInputParam(ActVisualTesting.Fields.ErrorMetric).Value?.Trim() ?? string.Empty, true, out eErrorMetric);
+
+                using (IMagickImage diffImg = magickBaseImg.Compare(magickTargetImg, eErrorMetric, Channels.Red, out percentageDifference))
+                {
+                    // Ensure a decoder-friendly format for GDI+
+                    diffImg.Format = MagickFormat.Png;
+
+                    percentageDifference = Math.Round(percentageDifference * 100, 2);
+
+                    TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
+                    using (Bitmap resultBmp = (Bitmap)tc.ConvertFrom(diffImg.ToByteArray()))
+                    {
+                        // Keep an owned copy beyond this scope
+                        mAct.CompareResult = (Bitmap)resultBmp.Clone();
+                        mAct.AddOrUpdateReturnParamActual("Percentage Difference", percentageDifference.ToString(System.Globalization.CultureInfo.InvariantCulture));
+                        mAct.AddScreenShot(resultBmp, "Compare Result");
+                    }
+                }
+            }

19-24: Add missing import for CultureInfo.

Required by the invariant ToString used in the diff above.

 using ImageMagick;
 using System;
+using System.Globalization;
 using System.ComponentModel;
 using System.Drawing;
Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (2)

326-336: Avoid C# 12 collection expressions unless LangVersion ≥ 12.

Use explicit List for broader compatibility.

Apply:

-                        List<string> temp = [];
+                        var temp = new List<string>();
...
-                                temp = [];
+                                temp = new List<string>();

401-413: Avoid C# 12 collection expressions unless LangVersion ≥ 12.

Use explicit List for compatibility.

Apply:

-                        List<ArtifactDetails> temp = [];
+                        var temp = new List<ArtifactDetails>();
...
-                                    temp = [];
+                                    temp = new List<ArtifactDetails>();
♻️ Duplicate comments (14)
Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/MagickAnalyzer.cs (2)

50-62: Add tests for the new Compare overload flow.

At least 1 identical-images case (0%), 1 non-identical (>0%), and assert that the returned diff image is valid/usable.

I can add unit tests under GingerCoreNET covering these cases if you want.


48-49: Trim/null-guard ErrorMetric parsing.

Prevents silent fallback on whitespace or null inputs.

-            Enum.TryParse<ErrorMetric>(mAct.GetOrCreateInputParam(ActVisualTesting.Fields.ErrorMetric).Value, true, out eErrorMetric);
+            Enum.TryParse<ErrorMetric>(mAct.GetOrCreateInputParam(ActVisualTesting.Fields.ErrorMetric).Value?.Trim() ?? string.Empty, true, out eErrorMetric);
Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (12)

174-194: Log when publish is skipped due to closed gate.

Downstream methods no-op silently; add skip log.

Apply:

-            if (restClient != null && _isRunSetDataSent)
+            if (restClient != null && _isRunSetDataSent)
             {
                 ...
             }
+            else
+            {
+                Reporter.ToLog(eLogLevel.INFO, $"Skipping Runner publish for '{accountReportRunner?.Name}': restClient null or RunSet not sent.");
+            }

198-210: Add skip log for BusinessFlow send.

Apply:

-            if (restClient != null && _isRunSetDataSent)
+            if (restClient != null && _isRunSetDataSent)
             {
                 ...
             }
+            else
+            {
+                Reporter.ToLog(eLogLevel.INFO, $"Skipping Business Flow publish for '{accountReportBusinessFlow?.Name}': restClient null or RunSet not sent.");
+            }

215-235: Add skip log for ActivityGroup send.

Apply:

-            if (restClient != null && _isRunSetDataSent)
+            if (restClient != null && _isRunSetDataSent)
             {
                 ...
             }
+            else
+            {
+                Reporter.ToLog(eLogLevel.INFO, $"Skipping Activity Group publish for '{accountReportActivityGroup?.Name}': restClient null or RunSet not sent.");
+            }

240-259: Add skip log for Activity send.

Apply:

-            if (restClient != null && _isRunSetDataSent)
+            if (restClient != null && _isRunSetDataSent)
             {
                 ...
             }
+            else
+            {
+                Reporter.ToLog(eLogLevel.INFO, $"Skipping Activity publish for '{accountReportActivity?.Name}': restClient null or RunSet not sent.");
+            }

264-283: Add skip log for Action send.

Apply:

-            if (restClient != null && _isRunSetDataSent)
+            if (restClient != null && _isRunSetDataSent)
             {
                 ...
             }
+            else
+            {
+                Reporter.ToLog(eLogLevel.INFO, $"Skipping Action publish for '{accountReportAction?.Name}': restClient null or RunSet not sent.");
+            }

316-352: Add skip log for screenshots send.

Apply:

-            if (restClient != null && _isRunSetDataSent)
+            if (restClient != null && _isRunSetDataSent)
             {
                 ...
             }
+            else
+            {
+                Reporter.ToLog(eLogLevel.INFO, $"Skipping screenshots upload for Execution Id '{executionId}': restClient null or RunSet not sent.");
+            }

357-387: Add skip log for UploadImageAsync.

Apply:

-            if (restClient != null && _isRunSetDataSent)
+            if (restClient != null && _isRunSetDataSent)
             {
                 ...
             }
+            else
+            {
+                Reporter.ToLog(eLogLevel.INFO, $"Skipping screenshot upload for Execution Id '{executionId}': restClient null or RunSet not sent.");
+            }

391-434: Add skip log for artifacts send.

Apply:

-            if (restClient != null && _isRunSetDataSent)
+            if (restClient != null && _isRunSetDataSent)
             {
                 ...
             }
+            else
+            {
+                Reporter.ToLog(eLogLevel.INFO, $"Skipping artifacts upload for Execution Id '{executionId}': restClient null or RunSet not sent.");
+            }

439-469: Add skip log for UploadArtifactsAsync.

Apply:

-            if (restClient != null && _isRunSetDataSent)
+            if (restClient != null && _isRunSetDataSent)
             {
                 ...
             }
+            else
+            {
+                Reporter.ToLog(eLogLevel.INFO, $"Skipping artifact upload for Execution Id '{executionId}': restClient null or RunSet not sent.");
+            }

50-54: Normalize GET_ACCOUNT_HTML_REPORT (remove leading slash).

One constant still has a leading “/” unlike the others; this can break base-URL joins.

Apply:

-        private const string GET_ACCOUNT_HTML_REPORT = "/api/HtmlReport/GetAccountHtmlReport/";
+        private const string GET_ACCOUNT_HTML_REPORT = "api/HtmlReport/GetAccountHtmlReport/";

127-127: Don’t open the gate at publish start.

Set false at start; only set true after success.

Apply:

-                    _isRunSetDataSent = true; //Resetting the flag again
+                    _isRunSetDataSent = false; // reset; open only after success

131-136: Emit explicit log before returning when update is blocked.

Helps triage why finish-update didn’t run.

Apply:

-                    if (!_isRunSetDataSent)
+                    if (!_isRunSetDataSent)
                     {
-                        // If this is an update and the RunSet was not previously sent successfully,
-                        // do not allow finishing update.
+                        // If this is an update and the RunSet was not previously sent successfully, do not allow finishing update.
+                        Reporter.ToLog(eLogLevel.INFO, $"Skipping RunSet update for '{accountReportRunSet?.Name}' because initial RunSet publish has not succeeded yet.");
                         return false;
                     }
📜 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.

📥 Commits

Reviewing files that changed from the base of the PR and between ce887c3 and e98d075.

📒 Files selected for processing (2)
  • Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/MagickAnalyzer.cs (1 hunks)
  • Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (13 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-06-14T09:40:41.306Z
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4226
File: Ginger/GingerCoreCommon/Functionalities/FindAndReplaceUtils.cs:457-461
Timestamp: 2025-06-14T09:40:41.306Z
Learning: In the ReplaceItemEnhanced method in FindAndReplaceUtils.cs, the Enum.TryParse call is intentionally case-sensitive (without the ignoreCase parameter), which is the expected behavior as confirmed by the user.

Applied to files:

  • Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/MagickAnalyzer.cs
📚 Learning: 2025-08-29T09:35:46.020Z
Learnt from: AmanPrasad43
PR: Ginger-Automation/Ginger#4286
File: Ginger/GingerCoreNET/External/ZAP/ZapProxyService.cs:287-309
Timestamp: 2025-08-29T09:35:46.020Z
Learning: In Ginger ZAP security testing, alert names should preserve their original formatting with spaces and hyphens. When comparing alert names in EvaluateScanResultAPI and similar methods, use StringComparison.OrdinalIgnoreCase for case-insensitive matching but do not normalize by removing spaces or hyphens, as alert names like "False Positive" need to remain as separate words. Confirmed by AmanPrasad43 in PR #4286.

Applied to files:

  • Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/MagickAnalyzer.cs
🧬 Code graph analysis (2)
Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/MagickAnalyzer.cs (1)
Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/ActVisualTesting.cs (1)
  • ActVisualTesting (36-635)
Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (1)
Ginger/GingerCoreCommon/ReporterLib/Reporter.cs (1)
  • Reporter (28-357)
🔇 Additional comments (2)
Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs (2)

151-161: LGTM: gate transitions only on actual result.

Setting true on success and false on failure is correct.


594-606: Confirm path join after constant normalization.

Once GET_ACCOUNT_HTML_REPORT is normalized (no leading “/”), this usage remains correct.

Comment thread Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/MagickAnalyzer.cs
@Maheshkale447
Maheshkale447 merged commit 4392871 into Releases/Beta Sep 5, 2025
9 of 10 checks passed
@Maheshkale447
Maheshkale447 deleted the Fetaure/VersionMismatch branch September 5, 2025 11:17
@coderabbitai coderabbitai Bot mentioned this pull request Nov 17, 2025
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant