Skip to content

Conversation

@abhisheks-gh
Copy link

@abhisheks-gh abhisheks-gh commented Aug 1, 2025

Summary

This PR adds support for automatically detecting the installed Microsoft Edge channel (Stable, Beta, Dev, or Canary) and dynamically updating the FetchPackages URL accordingly.

Key Changes

  • Added detectChannel() in CheckUpdate.java to determine which Edge channel is installed.
  • Main entry point (EdgeUpdateService.java) now auto-detects the channel and sets it before performing update.
  • Refactored FetchPackages to accept and apply dynamic channels.

Why This Is Needed

Previously, EUS only supported the Beta channel. Many users prefer Stable or Dev versions. This change makes EUS more flexible and production-friendly.

Related Issue

Fixes #6

Summary by CodeRabbit

  • New Features

    • Automatically detects your installed Microsoft Edge channel (stable/beta/dev/canary) and uses it during updates; prints the detected channel.
  • Bug Fixes

    • More reliable current Edge version detection with safer fallbacks to avoid failures.
    • Improved handling when Edge isn’t immediately detectable.
  • Chores

    • Channel-aware update flow and dependency checks for smoother, channel-appropriate installations.

abhisheks-gh and others added 2 commits August 2, 2025 01:26
- Introduced a detectChannel() method in CheckUpdate.java that:
  - Checks if the default  executable exists and parses the version string to detect channel (e.g., stable, beta, dev).
  - Falls back to checking common insider build executables (, , etc.) if default fails.
- Updated EdgeUpdateService.java (main method) to:
  - Automatically detect the installed channel before performing update.
  - Set the detected channel via FetchPackages.setChannel() dynamically.
- Updated FetchPackages to support dynamic channel configuration instead of hardcoding .

This ensures the update mechanism works across Stable, Beta, Dev, and Canary channels without user input.

Related to issue: SaptarshiSarkar12#6
@SaptarshiSarkar12
Copy link
Owner

@abhisheks-gh There are some syntax errors in the Java classes. Can you please fix those?
Check the build log for more details.

@abhisheks-gh abhisheks-gh force-pushed the feat/detect-channel-support branch from 1e7f07e to 104dafb Compare August 4, 2025 07:27
@abhisheks-gh
Copy link
Author

Hi @SaptarshiSarkar12 , I have fixed those errors - check once and let me know.

Copy link
Owner

@SaptarshiSarkar12 SaptarshiSarkar12 left a comment

Choose a reason for hiding this comment

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

@abhisheks-gh Thank you for the PR! Great work 👏.
I have reviewed the PR; check the comments below.
One more thing I would like to say is that in

if (line.contains("microsoft-edge-beta") && line.contains("amd64.deb")) {
the channel name is hardcoded and doesn't change dynamically. It's currently microsoft-edge-beta.

Copy link
Owner

Choose a reason for hiding this comment

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

The checkInitDeps() method looks for microsoft-edge-beta by default. Do you have any idea to fix that? We can check and update the channel at the start of the application. We can then use the channel to check for deps and then proceed further.

Copy link
Owner

Choose a reason for hiding this comment

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

@abhisheks-gh I think this issue has not been solved yet. Can you please figure out a solution for this problem?

Copy link
Owner

Choose a reason for hiding this comment

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

In the updateEdge() method, the link is hardcoded and doesn't dynamically change with the channel.
This is the line I'm talking about: utils.SystemOps.downloadEdgePackage("https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-beta/" + latestPkg);

Copy link
Owner

Choose a reason for hiding this comment

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

@abhisheks-gh This issue also needs fixing. I think we can introduce a static variable (maybe called as channel) in the EdgeUpdateService class, which will be set by the detectInstalledChannel method. We can then use that static variable everywhere required.

abhisheks-gh and others added 5 commits August 12, 2025 15:08
- Deleted checkInsiderExecutables() as it is now redundant
- Fallback logic for insider channel detection is already handled in detectInstalledChannel()
- No other code references this method
Changed path to - "/usr/bin/microsoft-edge-beta"

public static String detectInstalledChannel() {
try {
ProcessBuilder pb = new ProcessBuilder("microsoft-edge", "--version");

Check warning

Code scanning / CodeQL

Executing a command with a relative path Medium

Command with a relative path 'microsoft-edge' is executed.
@SaptarshiSarkar12
Copy link
Owner

Hi @abhisheks-gh 👋!
Thank you for all the fixes. I’m unwell right now, but I’ll review your PR as soon as I recover.

@abhisheks-gh
Copy link
Author

Hi @abhisheks-gh 👋!
Thank you for all the fixes. I’m unwell right now, but I’ll review your PR as soon as I recover.

Hi @SaptarshiSarkar12 , no rush as I still need to check and fix a few things on my end and will do so when I get time. Wishing you a speedy recovery.

@SaptarshiSarkar12
Copy link
Owner

Hi @abhisheks-gh 👋!
Thank you for the kind words. I am now fully recovered. Once you are done with all the reviews previously published, you can request for a review. I'll review it as soon as possible.

@abhisheks-gh
Copy link
Author

Hi @SaptarshiSarkar12 , Glad to hear that you had a quick recovery. Could you please review the PR now. I believe, we are good to go. Thanks!

@SaptarshiSarkar12
Copy link
Owner

SaptarshiSarkar12 commented Sep 2, 2025

Hi @SaptarshiSarkar12 , Glad to hear that you had a quick recovery. Could you please review the PR now. I believe, we are good to go. Thanks!

Hi @abhisheks-gh 👋! Thank you for the kind words.
I apologise for the delay. Sure, I'll review the PR soon. Thank you for your cooperation.

@SaptarshiSarkar12
Copy link
Owner

@abhisheks-gh I have left 2 comments in the previous review comments. Please check those out and inform me once completed. Let me know if you have any questions.
Links to those comments:

@coderabbitai
Copy link

coderabbitai bot commented Sep 2, 2025

📝 Walkthrough

Walkthrough

Detects the installed Edge channel, sets FetchPackages.channel accordingly, updates the update flow to accept a channel, builds channel-specific package URLs using a helper to map channel→binary name, adds channel-detection API, and refactors Edge version retrieval to stream-read and parse process output.

Changes

Cohort / File(s) Summary
Edge update flow: channel-aware
src/main/java/main/EdgeUpdateService.java
updateEdge()updateEdge(String channel); no-arg path detects channel, calls FetchPackages.setChannel(...), uses new getEdgeBinaryName(channel) to compute pkgPath and build channel-specific download URL; retains install/cleanup flow.
Channel detection utility
src/main/java/utils/CheckUpdate.java
Adds public static String detectInstalledChannel() which runs microsoft-edge --version, parses output for beta/dev/canary, falls back to command-availability checks, returns channel or "stable"/null per fallback logic.
Package fetch config
src/main/java/utils/FetchPackages.java
channel changed to mutable (private static String channel = "beta"); adds public static void setChannel(String) with validation; existing final pkgLink remains initialized earlier.
System ops: version retrieval
src/main/java/utils/SystemOps.java
Reimplements getCurrentEdgeVersion() to invoke Edge binary via ProcessBuilder, read first line with BufferedReader, parse with new extractVersion(...), and return "0.0.0.0" on failure.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant EdgeUpdateService
  participant CheckUpdate
  participant FetchPackages
  participant Repo as packages.microsoft.com
  participant SystemOps

  User->>EdgeUpdateService: execute()
  EdgeUpdateService->>CheckUpdate: detectInstalledChannel()
  CheckUpdate-->>EdgeUpdateService: channel (stable|beta|dev|canary|null)
  EdgeUpdateService->>FetchPackages: setChannel(channel)
  EdgeUpdateService->>EdgeUpdateService: getEdgeBinaryName(channel)
  EdgeUpdateService->>Repo: GET /repos/edge/pool/.../{pkgPath}/{latestPkg}
  Repo-->>EdgeUpdateService: .deb package
  EdgeUpdateService->>SystemOps: getCurrentEdgeVersion()
  SystemOps-->>EdgeUpdateService: current version
  EdgeUpdateService->>EdgeUpdateService: install/update (.deb) & cleanup
  EdgeUpdateService-->>User: done / status
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I hop the bytes and sniff the stream,
Stable, Beta, Dev — each has its dream.
I set the channel, fetch the pack,
Tidy the warren, bounce right back.
A rabbit's cheer for every build! 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The changes in SystemOps.java to getCurrentEdgeVersion() appear to be out of scope relative to the linked issue #6 requirements. The issue specifically requested centralizing package URLs, auto-detecting the installed channel, and checking updates for multiple browsers, but did not mention refactoring the version retrieval mechanism. The SystemOps changes rewrite getCurrentEdgeVersion to use ProcessBuilder with a hardcoded "/usr/bin/microsoft-edge" path and introduce a new extractVersion helper method, which modifies the version-fetching implementation in ways unrelated to channel detection or URL centralization objectives. The SystemOps.java refactoring should be evaluated to determine if it's an intentional improvement or an unrelated change. If it's a deliberate enhancement to support channel detection (e.g., ensuring version detection works across channels), this rationale should be documented. Otherwise, consider moving these changes to a separate PR focused on refactoring version retrieval, keeping this PR focused solely on channel detection and support as specified in issue #6.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "feat: add support for automatic channel detection (stable/beta/dev/canary)" clearly and accurately summarizes the main change in this pull request. The changeset introduces automatic detection of the installed Microsoft Edge channel and adds support for multiple channels (stable, beta, dev, canary), which is precisely what the title conveys. The title is concise, specific, and provides a clear understanding of the primary functionality being added without being overly broad or vague.
Linked Issues Check ✅ Passed The code changes successfully address all three core objectives from linked issue #6. The PR centralizes URL handling and makes it channel-aware by introducing getEdgeBinaryName(String channel) and modifying updateEdge to accept a channel parameter that constructs the appropriate package URL dynamically. Auto-detection of the installed Edge channel is implemented through the new CheckUpdate.detectInstalledChannel() method, which examines the installed Edge version command output and falls back to checking for available binaries. The FetchPackages class now supports dynamic channel configuration via the new setChannel(String newChannel) method, and EdgeUpdateService's main method detects and applies the channel before updating. While the issue mentioned checking updates for multiple concurrent Edge installations, the implementation focuses on detecting and updating a single detected channel, which represents the primary use case and aligns with the core requirements.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8342334 and b3e1a38.

📒 Files selected for processing (1)
  • src/main/java/utils/CheckUpdate.java (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: SaptarshiSarkar12
PR: SaptarshiSarkar12/EdgeUpdateService#9
File: src/main/java/utils/SystemOps.java:19-33
Timestamp: 2025-09-06T17:30:57.843Z
Learning: On Linux systems, the `microsoft-edge` executable is present regardless of which Edge channel (stable/beta/dev/canary) is installed, so there's no need to check multiple binary candidates when getting the Edge version.
📚 Learning: 2025-09-06T17:30:57.843Z
Learnt from: SaptarshiSarkar12
PR: SaptarshiSarkar12/EdgeUpdateService#9
File: src/main/java/utils/SystemOps.java:19-33
Timestamp: 2025-09-06T17:30:57.843Z
Learning: On Linux systems, the `microsoft-edge` executable is present regardless of which Edge channel (stable/beta/dev/canary) is installed, so there's no need to check multiple binary candidates when getting the Edge version.

Applied to files:

  • src/main/java/utils/CheckUpdate.java
🧬 Code graph analysis (1)
src/main/java/utils/CheckUpdate.java (1)
src/main/java/utils/SystemOps.java (1)
  • SystemOps (12-195)
🔇 Additional comments (5)
src/main/java/utils/CheckUpdate.java (5)

3-5: LGTM!

The new imports are necessary for reading command output in detectInstalledChannel().


11-12: CRITICAL: Static initialization order hazard remains unresolved.

This is the same critical issue flagged in a previous review: packages is loaded at class initialization via FetchPackages.getPackages() before the channel is detected and set. This causes the wrong packages to be fetched (defaulting to beta), even when Stable, Dev, or Canary is installed.

The channel must be detected and set before calling FetchPackages.getPackages(). As suggested in the previous review, either:

Option A: Detect channel during static initialization and set it before fetching packages:

private static final String channel = detectInstalledChannel();
static { 
    if (channel != null) {
        FetchPackages.setChannel(channel); 
    }
}
private static final List<String> packages = FetchPackages.getPackages();

Option B: Refactor FetchPackages.getPackages() to accept a channel parameter:

private static final String channel = detectInstalledChannel();
private static final List<String> packages = FetchPackages.getPackages(channel);

66-66: CRITICAL: Use absolute path to prevent command injection.

The code uses a relative path "microsoft-edge" which CodeQL has flagged as a security risk (executing a command with a relative path). An attacker could potentially place a malicious microsoft-edge executable earlier in the PATH.

Apply this diff to use the absolute path:

-        ProcessBuilder pb = new ProcessBuilder("microsoft-edge", "--version");
+        ProcessBuilder pb = new ProcessBuilder("/usr/bin/microsoft-edge", "--version");

Based on learnings (microsoft-edge executable is always present regardless of channel).


88-88: Null return is safely handled by all callers.

The method returns null when channel detection fails, but both call sites handle this correctly:

  1. Line 30-33 in EdgeUpdateService.java: Explicit null check with fallback to "stable"
  2. Line 42-43 in checkInitDeps(): Passes to getEdgeBinaryName(), which safely handles null using the null-safe pattern "literal".equals(channel) and returns "microsoft-edge" as default

No NullPointerException risk exists.


81-86: The fallback logic is correct and necessary.

The fallback checks for channel-specific binaries (microsoft-edge-beta, microsoft-edge-dev, microsoft-edge-canary) are valid. Official Microsoft Edge Linux installations use these channel-specific executable names for different Edge channels:

  • Stable: microsoft-edge
  • Beta: microsoft-edge-beta
  • Dev: microsoft-edge-dev
  • Canary: microsoft-edge-canary

This fallback logic appropriately handles cases where the primary detection method fails and provides a way to identify which Edge channel is installed.

Likely an incorrect or invalid review comment.


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
🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

♻️ Duplicate comments (2)
src/main/java/utils/CheckUpdate.java (1)

65-90: Channel detection uses a relative binary and misses stable fallback; make it robust and absolute.

  • Re-introduces the “relative path” issue previously flagged by code scanning. Prefer absolute paths.
  • If the microsoft-edge invocation fails, there’s no stable fallback in the catch branch.
  • Prefer checking for channel-specific binaries first, then parse output if needed.
-    public static String detectInstalledChannel() {
-    try {
-        ProcessBuilder pb = new ProcessBuilder("microsoft-edge", "--version");
-        Process process = pb.start();
-
-        try (BufferedReader reader = new BufferedReader(
-                new InputStreamReader(process.getInputStream()))) {
-
-            String output = reader.readLine();
-            if (output != null) {
-                output = output.toLowerCase();
-                if (output.contains("beta")) return "beta";
-                if (output.contains("dev")) return "dev";
-                if (output.contains("canary")) return "canary";
-                return "stable"; // default if none found
-            }
-        }
-    } catch (IOException e) {
-        // Fallback: check for insider builds
-        if (SystemOps.isCommandAvailable("microsoft-edge-beta")) return "beta";
-        if (SystemOps.isCommandAvailable("microsoft-edge-dev")) return "dev";
-        if (SystemOps.isCommandAvailable("microsoft-edge-canary")) return "canary";
-    }
-    // If everything fails
-    return null;
-}
+    public static String detectInstalledChannel() {
+        // Prefer explicit binaries first
+        if (SystemOps.isCommandAvailable("microsoft-edge-canary")) return "canary";
+        if (SystemOps.isCommandAvailable("microsoft-edge-dev"))    return "dev";
+        if (SystemOps.isCommandAvailable("microsoft-edge-beta"))   return "beta";
+        if (SystemOps.isCommandAvailable("microsoft-edge") || SystemOps.isCommandAvailable("microsoft-edge-stable"))
+            return "stable";
+
+        // Fallback: try reading version output from stable path if present
+        try {
+            ProcessBuilder pb = new ProcessBuilder("/usr/bin/microsoft-edge", "--version");
+            Process process = pb.start();
+            try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
+                String output = reader.readLine();
+                if (output != null) {
+                    String out = output.toLowerCase();
+                    if (out.contains("canary")) return "canary";
+                    if (out.contains("dev"))    return "dev";
+                    if (out.contains("beta"))   return "beta";
+                    return "stable";
+                }
+            }
+        } catch (IOException ignored) {
+            // no-op
+        }
+        // Final default
+        return "stable";
+    }

Optional: If you want to avoid duplicating path resolution, expose SystemOps.getCommandPath as public:

// In SystemOps.java
-    private static String getCommandPath(String command) {
+    public static String getCommandPath(String command) {
src/main/java/main/EdgeUpdateService.java (1)

37-42: Past comment addressed: deps now use channel-specific binary.

The dependency list now uses a channel-derived Edge binary instead of the previous hardcoded microsoft-edge-beta. Once the stable mapping fix (see below) is applied, this fully resolves the earlier feedback.

🧹 Nitpick comments (2)
src/main/java/utils/FetchPackages.java (1)

15-22: Harden setChannel: normalize input and avoid misleading log.

Trim/case-normalize input; if invalid, say you’re keeping the current channel (not “default: beta”) to avoid confusion.

 public static void setChannel(String newChannel) {
-        if (List.of("stable", "beta", "dev", "canary").contains(newChannel)) {
+        if (newChannel != null) newChannel = newChannel.trim().toLowerCase();
+        if (List.of("stable", "beta", "dev", "canary").contains(newChannel)) {
             channel = newChannel;
         } else {
-            System.out.println("Invalid channel. Using default: beta.");
+            System.out.println("Invalid channel '" + newChannel + "'. Keeping current: " + channel);
         }
     }
src/main/java/utils/SystemOps.java (1)

7-7: Remove unused import.

java.nio.Buffer is unused.

-import java.nio.Buffer;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

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 8cf55b2 and 98b1f14.

📒 Files selected for processing (4)
  • src/main/java/main/EdgeUpdateService.java (3 hunks)
  • src/main/java/utils/CheckUpdate.java (2 hunks)
  • src/main/java/utils/FetchPackages.java (1 hunks)
  • src/main/java/utils/SystemOps.java (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/main/java/main/EdgeUpdateService.java (3)
src/main/java/utils/CheckUpdate.java (1)
  • CheckUpdate (10-93)
src/main/java/utils/FetchPackages.java (1)
  • FetchPackages (9-44)
src/main/java/utils/SystemOps.java (1)
  • SystemOps (12-195)
src/main/java/utils/CheckUpdate.java (2)
src/main/java/utils/SystemOps.java (1)
  • SystemOps (12-195)
src/main/java/utils/FetchPackages.java (1)
  • FetchPackages (9-44)
🔇 Additional comments (2)
src/main/java/utils/CheckUpdate.java (1)

3-5: LGTM on imports.

Required for process output parsing and exception handling.

src/main/java/main/EdgeUpdateService.java (1)

77-82: No change needed for stable binary name
The CLI binary for stable releases is microsoft-edge (the repo/package name is microsoft-edge-stable), so the existing default return is correct. If you need to derive the Debian/Ubuntu package or repo path, introduce a separate mapping or helper rather than conflating binary names with package names.

Likely an incorrect or invalid review comment.


public class FetchPackages {
private static final String channel = "beta";
private static String channel = "beta"; // Default if not overridden
Copy link

@coderabbitai coderabbitai bot Sep 2, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Channel is mutable but URL is not; plus HttpClient is used incorrectly (compilation failure).

  • Bug 1: channel can change, but pkgLink is final and captured at class-load time. Any later setChannel() has no effect on the URL.
  • Bug 2: HttpClient is not AutoCloseable; using it in try-with-resources won’t compile.

Fix both by computing the URL on demand and removing the try-with-resources; also add basic status/timeout handling.

-    private static final String pkgLink = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-" + channel + "/";
+    // URL computed on demand from current channel

@@
-    private static String getResponse() {
-        try (HttpClient client = HttpClient.newHttpClient()) {
-            HttpRequest request = HttpRequest.newBuilder()
-                    .uri(URI.create(pkgLink))
-                    .GET()
-                    .build();
-            return client.send(request, HttpResponse.BodyHandlers.ofString()).body();
-        } catch (Exception e) {
-            System.out.println("Error: " + e.getMessage());
-            return null;
-        }
-    }
+    private static String getResponse() {
+        try {
+            HttpClient client = HttpClient.newBuilder()
+                    .connectTimeout(java.time.Duration.ofSeconds(10))
+                    .build();
+            HttpRequest request = HttpRequest.newBuilder()
+                    .uri(URI.create(buildPkgLink()))
+                    .timeout(java.time.Duration.ofSeconds(10))
+                    .GET()
+                    .build();
+            HttpResponse<String> resp = client.send(request, HttpResponse.BodyHandlers.ofString());
+            if (resp.statusCode() >= 200 && resp.statusCode() < 300) {
+                return resp.body();
+            }
+            System.out.println("HTTP " + resp.statusCode() + " when fetching packages for channel: " + channel);
+            return null;
+        } catch (Exception e) {
+            System.out.println("Error: " + e.getMessage());
+            return null;
+        }
+    }

Add this helper (outside the shown range):

private static String buildPkgLink() {
    String dir = "stable".equals(channel) ? "microsoft-edge-stable" : "microsoft-edge-" + channel;
    return "https://packages.microsoft.com/repos/edge/pool/main/m/" + dir + "/";
}

Also applies to: 11-11, 24-35

🤖 Prompt for AI Agents
In src/main/java/utils/FetchPackages.java around lines 10 (also apply fixes at
11 and 24-35): the class currently defines a mutable static channel but captures
the package URL in a final field at class-load time and uses HttpClient inside a
try-with-resources (which fails to compile because HttpClient is not
AutoCloseable). Change to compute the package URL on demand via a helper method
(e.g., buildPkgLink() that returns the URL based on the current channel) instead
of a final pkgLink constant, remove the try-with-resources around HttpClient and
instantiate a single HttpClient normally (not closed), and add basic HTTP status
checking and a request timeout when sending the request so failures/timeouts are
handled and updated channel values affect the computed URL.

Copy link
Owner

Choose a reason for hiding this comment

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

@abhisheks-gh The changes suggested by the bot is correct and must be applied to fix the bug.

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link

@coderabbitai coderabbitai bot left a 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

♻️ Duplicate comments (3)
src/main/java/main/EdgeUpdateService.java (3)

59-61: Bug: latestPkg may be from the wrong channel (beta) — pass channel through.

CheckUpdate.getLatestPkgName() reads a static, eagerly-fetched package list that’s frozen to beta. You must request the list for the same channel you download from.

Apply:

-        String latestPkg = CheckUpdate.getLatestPkgName();
+        String latestPkg = CheckUpdate.getLatestPkgName(channel); // per-channel

Note: Update utils/CheckUpdate.java to accept a channel and to remove the static eager fetch so it respects utils.FetchPackages.setChannel(channel).


29-37: Detect once, then use it for deps and update; avoid early static init and duplication.

Current flow detects here and also inside checkInitDeps(), while checkInitDeps() is called earlier. Detect once, set channel, then run deps and update to avoid initializing CheckUpdate (and its beta-frozen packages) twice.

Apply:

             utils.FetchPackages.setChannel(detectedChannel);
             System.out.println("Detected channel: " + detectedChannel);
-
-            updateEdge(detectedChannel);
+            checkInitDeps(detectedChannel); // move deps check here
+            updateEdge(detectedChannel);

Also remove the early call to checkInitDeps() near Line 14 (outside this hunk) to prevent double init.


41-47: Don’t re-detect here; accept the channel and use it for deps.

Make deps check pure and parameterized; drop the extra detect that triggers CheckUpdate’s static init.

Apply:

-    private static void checkInitDeps() {
-        String detectedChannel = CheckUpdate.detectInstalledChannel();
-        String edgeBinary = getEdgeBinaryName(detectedChannel);
+    private static void checkInitDeps(String channel) {
+        if (channel == null) channel = "stable";
+        String edgeBinary = getEdgeBinaryName(channel);

Call site: use checkInitDeps(detectedChannel) after detection (see comment on Lines 29–37).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

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 98b1f14 and 8342334.

📒 Files selected for processing (1)
  • src/main/java/main/EdgeUpdateService.java (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/main/java/main/EdgeUpdateService.java (3)
src/main/java/utils/CheckUpdate.java (1)
  • CheckUpdate (10-93)
src/main/java/utils/FetchPackages.java (1)
  • FetchPackages (9-44)
src/main/java/utils/SystemOps.java (1)
  • SystemOps (12-195)

Comment on lines +59 to +72
public static void updateEdge(String channel) {
String latestPkg = CheckUpdate.getLatestPkgName();
if (latestPkg == null) {
System.out.println("No Edge update available.");
} else {
String pkgPath = getEdgeBinaryName(channel);

System.out.println("Latest Package: " + latestPkg);
System.out.println("New Edge update is available.");
System.out.println("Downloading the latest package...");
utils.SystemOps.downloadEdgePackage("https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-beta/" + latestPkg);

utils.SystemOps.downloadEdgePackage(
"https://packages.microsoft.com/repos/edge/pool/main/m/" + pkgPath + "/" + latestPkg
);
Copy link

@coderabbitai coderabbitai bot Sep 2, 2025

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify and fix upstream static-initialization pitfalls in utils.

FetchPackages.pkgLink is static final and computed with "beta"; CheckUpdate holds a static List packages. Both must be de-staticized/lazily fetched per channel to make the above changes effective.

Run:


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "Check for static eager fetches:"
rg -nP 'private\s+static\s+final\s+String\s+pkgLink' -C2 -- glob:'**/src/main/java/**/*.java'
rg -nP 'private\s+static\s+final\s+List<\s*String\s*>\s*packages' -C2 -- glob:'**/src/main/java/**/*.java'
rg -nP '\bHttpRequest\.newHttpRequestBuilder\(' -C2 -- glob:'**/src/main/java/**/*.java' # invalid builder; should be newBuilder()
rg -nP '\bgetLatestPkgName\s*\(' -C2 -- glob:'**/src/main/java/**/*.java'

Length of output: 260


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "Directories at root level:"
find . -maxdepth 2 -type d

Length of output: 239


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "Checking for static eager fetches and builder usage:"
rg -nP 'private\s+static\s+final\s+String\s+pkgLink' -C2 --glob 'src/main/java/**/*.java'
rg -nP 'private\s+static\s+final\s+List<\s*String\s*>\s*packages' -C2 --glob 'src/main/java/**/*.java'
rg -nP 'HttpRequest\.newHttpRequestBuilder' -C2 --glob 'src/main/java/**/*.java'
rg -nP 'getLatestPkgName\s*\(' -C2 --glob 'src/main/java/**/*.java'

Length of output: 1375


De-staticize static pkgLink and packages for channel-specific updates
FetchPackages.pkgLink (utils/FetchPackages.java:11) and CheckUpdate.packages (utils/CheckUpdate.java:12) are both static final and use the default "beta" channel at class load, causing updateEdge(channel) to always target beta. Refactor to generate pkgLink and packages lazily per channel parameter.

🤖 Prompt for AI Agents
In src/main/java/main/EdgeUpdateService.java around lines 59-72,
updateEdge(String channel) uses helpers that read static final fields
pre-initialized to the "beta" channel; change the code and the helper classes so
pkgLink and packages are computed per-channel at runtime. Specifically, remove
or stop using static final pkgLink/packages in utils/FetchPackages and
utils/CheckUpdate, add methods that accept a channel parameter (e.g.,
FetchPackages.getPkgLink(channel) and CheckUpdate.getPackages(channel) or
constructors that take channel), update updateEdge to call those channel-aware
methods to build the download URL, and ensure any caching is done per-channel
(not as a single static field) and is thread-safe. Ensure all call sites are
updated accordingly.

Copy link
Owner

Choose a reason for hiding this comment

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

@abhisheks-gh Take a look at this. We need to initialise the pkgLink variable after the channel is fetched.

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@abhisheks-gh
Copy link
Author

@abhisheks-gh I have left 2 comments in the previous review comments. Please check those out and inform me once completed. Let me know if you have any questions.
Links to those comments:

Hi @SaptarshiSarkar12 , I've resolved the concerns you highlighted. You can check it back now. Also, there are some suggestions from the action bot that you may look at. Thanks

@SaptarshiSarkar12
Copy link
Owner

Thank you @abhisheks-gh for the quick fixes. I will review it soon.

Copy link
Owner

@SaptarshiSarkar12 SaptarshiSarkar12 left a comment

Choose a reason for hiding this comment

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

@abhisheks-gh Awesome work 👏. Left a few comments. Please look into those.


public class FetchPackages {
private static final String channel = "beta";
private static String channel = "beta"; // Default if not overridden
Copy link
Owner

Choose a reason for hiding this comment

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

@abhisheks-gh The changes suggested by the bot is correct and must be applied to fix the bug.

Comment on lines +59 to +72
public static void updateEdge(String channel) {
String latestPkg = CheckUpdate.getLatestPkgName();
if (latestPkg == null) {
System.out.println("No Edge update available.");
} else {
String pkgPath = getEdgeBinaryName(channel);

System.out.println("Latest Package: " + latestPkg);
System.out.println("New Edge update is available.");
System.out.println("Downloading the latest package...");
utils.SystemOps.downloadEdgePackage("https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-beta/" + latestPkg);

utils.SystemOps.downloadEdgePackage(
"https://packages.microsoft.com/repos/edge/pool/main/m/" + pkgPath + "/" + latestPkg
);
Copy link
Owner

Choose a reason for hiding this comment

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

@abhisheks-gh Take a look at this. We need to initialise the pkgLink variable after the channel is fetched.

abhisheks-gh and others added 2 commits September 30, 2025 00:33
Removed channel string that was storing result from detectInstalledChannel()

Co-authored-by: Saptarshi Sarkar <[email protected]>
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.

[FEAT]: Add support for other Edge channels

2 participants