Skip to content

Watcher exception resolved#318

Open
msivasubramaniaan wants to merge 4 commits into
redhat-developer:mainfrom
msivasubramaniaan:resolve-watcher-exception
Open

Watcher exception resolved#318
msivasubramaniaan wants to merge 4 commits into
redhat-developer:mainfrom
msivasubramaniaan:resolve-watcher-exception

Conversation

@msivasubramaniaan

Copy link
Copy Markdown
Collaborator

Signed-off-by: msivasubramaniaan <msivasub@redhat.com>
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@msivasubramaniaan, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 17 minutes and 40 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 6c37259c-8e93-4a41-94b2-b69a4bb392e0

📥 Commits

Reviewing files that changed from the base of the PR and between ed78286 and 261f579.

📒 Files selected for processing (1)
  • src/main/kotlin/com/redhat/devtools/gateway/devworkspace/DevWorkspaces.kt
📝 Walkthrough

Walkthrough

DevWorkspaceWatchManager drops its ApiClient constructor parameter and changes start() from a nullable map to a non-null Map<String, String?> defaulting to emptyMap(). The view layer removes the private val qualifier from its client parameter, guards lastResourceVersions writes against null resourceVersions, and cleans up an unused import and an intermediate try-expression shape. Utility methods in DevWorkspaces improve error handling for template lookups and update timing units.

Changes

DevWorkspaceWatchManager API cleanup and downstream adaptation

Layer / File(s) Summary
DevWorkspaceWatchManager: remove ApiClient, non-null lastResourceVersions
src/main/kotlin/com/redhat/devtools/gateway/devworkspace/DevWorkspaceWatcher.kt
Removes ApiClient, Projects, and Utils imports; drops the client: ApiClient constructor parameter from DevWorkspaceWatchManager; changes start() to accept Map<String, String?> defaulting to emptyMap(); watcher initialization destructures (ns, resourceVersion) directly from map entries.
View adaptation: inline client, null-safe resourceVersion, cleanup
src/main/kotlin/com/redhat/devtools/gateway/view/steps/DevSpacesWorkspacesStepView.kt
Removes unused MessageDialogBuilder import; removes private val from WorkspacesWatch client parameter; guards lastResourceVersions[namespace] assignment with non-null check on resourceVersion; refactors onNext() to use direct try-block around getServerStatus().
DevWorkspaces utility improvements: error handling and timing
src/main/kotlin/com/redhat/devtools/gateway/devworkspace/DevWorkspaces.kt
Reorders imports; upgrades time unit from milliseconds to seconds; refactors getTemplateMap() to safely handle missing items and return emptyMap() for HTTP 403 errors while rethrowing other exceptions; simplifies exception handling in waitPhaseChanges retry loop.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Watcher exception resolved' is related to the changeset and clearly indicates the main fix involves resolving a watcher exception, matching the commit message and PR objectives.
Description check ✅ Passed The description provides a Jira ticket reference (CRW-11309) which directly relates to the watcher exception issue addressed in the changeset; it is relevant despite being minimal.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

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

@codecov-commenter

codecov-commenter commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 23.44%. Comparing base (71098f6) to head (261f579).
⚠️ Report is 358 commits behind head on main.

Files with missing lines Patch % Lines
...hat/devtools/gateway/devworkspace/DevWorkspaces.kt 0.00% 20 Missing ⚠️
.../gateway/view/steps/DevSpacesWorkspacesStepView.kt 0.00% 5 Missing ⚠️
...vtools/gateway/devworkspace/DevWorkspaceWatcher.kt 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            main     #318       +/-   ##
==========================================
+ Coverage   0.00%   23.44%   +23.44%     
==========================================
  Files          4      101       +97     
  Lines         26     4201     +4175     
  Branches       0      777      +777     
==========================================
+ Hits           0      985      +985     
- Misses        26     3085     +3059     
- Partials       0      131      +131     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/kotlin/com/redhat/devtools/gateway/devworkspace/DevWorkspaceWatcher.kt (1)

89-89: Keep the explicit parameter requirement for clarity, but this is optional refactoring.

The default argument emptyMap() is never invoked in the current codebase—all start() calls in DevSpacesWorkspacesStepView.kt explicitly pass lastResourceVersions (e.g., line 192), so there is no actual silent no-op risk today. However, removing the default argument is still good practice to make the API contract explicit and prevent future callers from accidentally omitting namespaces. Consider:

-    fun start(lastResourceVersions: Map<String, String?> = emptyMap()) {
+    fun start(lastResourceVersions: Map<String, String?>) {

Apply the same change to the WorkspacesWatch.start() wrapper (line 572 in DevSpacesWorkspacesStepView.kt).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/kotlin/com/redhat/devtools/gateway/devworkspace/DevWorkspaceWatcher.kt`
at line 89, Remove the default argument `emptyMap()` from the
`lastResourceVersions` parameter in the `start` function signature in
DevWorkspaceWatcher to make the API contract explicit and prevent future callers
from accidentally omitting this required parameter. Since all current callers
explicitly pass the argument anyway, this change will not break existing code.
Apply the same refactoring to the `WorkspacesWatch.start()` wrapper method in
DevSpacesWorkspacesStepView.kt to keep the API consistent across both
implementations.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/kotlin/com/redhat/devtools/gateway/view/steps/DevSpacesWorkspacesStepView.kt`:
- Around line 208-210: The current code uses a conditional let block that only
adds the namespace to lastResourceVersions when resourceVersion is not null,
which prevents namespaces with null resourceVersion from being included in the
map. Since DevWorkspaceWatchManager.start() iterates over map entries to create
watchers, missing namespaces will never have their watchers started. Modify the
code to always add the namespace entry to lastResourceVersions regardless of
whether dwListResult.resourceVersion is null, and only update the value when
resourceVersion is present. This ensures all namespaces are tracked in the map
and can be processed by the watcher manager.

---

Nitpick comments:
In
`@src/main/kotlin/com/redhat/devtools/gateway/devworkspace/DevWorkspaceWatcher.kt`:
- Line 89: Remove the default argument `emptyMap()` from the
`lastResourceVersions` parameter in the `start` function signature in
DevWorkspaceWatcher to make the API contract explicit and prevent future callers
from accidentally omitting this required parameter. Since all current callers
explicitly pass the argument anyway, this change will not break existing code.
Apply the same refactoring to the `WorkspacesWatch.start()` wrapper method in
DevSpacesWorkspacesStepView.kt to keep the API consistent across both
implementations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 0a2909c3-dff7-41cf-830e-7a7d3d9a7d25

📥 Commits

Reviewing files that changed from the base of the PR and between c4fdb82 and c8709c0.

📒 Files selected for processing (2)
  • src/main/kotlin/com/redhat/devtools/gateway/devworkspace/DevWorkspaceWatcher.kt
  • src/main/kotlin/com/redhat/devtools/gateway/view/steps/DevSpacesWorkspacesStepView.kt

Signed-off-by: msivasubramaniaan <msivasub@redhat.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/kotlin/com/redhat/devtools/gateway/devworkspace/DevWorkspaces.kt (1)

287-287: ⚡ Quick win

Avoid re-creating DevWorkspaces inside the poll loop

This loop runs every second; DevWorkspaces(client).get(...) allocates a new wrapper each iteration. Use get(namespace, name) directly on the current instance.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/kotlin/com/redhat/devtools/gateway/devworkspace/DevWorkspaces.kt` at
line 287, The poll loop that runs every second is inefficiently re-allocating a
new DevWorkspaces wrapper instance on each iteration by calling
DevWorkspaces(client).get(namespace, name). Instead, call the get method
directly on the current DevWorkspaces instance to avoid unnecessary object
allocation in the tight polling loop.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/kotlin/com/redhat/devtools/gateway/devworkspace/DevWorkspaces.kt`:
- Around line 286-290: The catch block in the retry loop within DevWorkspaces is
currently catching all Exception types, which means it will retry on permanent
failures like authentication or permission errors instead of failing fast.
Replace the generic catch (_: Exception) clause to only catch
transient/temporary failure exceptions (such as timeout exceptions, connection
reset exceptions, or temporary HTTP status codes like 429 or 503). Let other
exceptions like authentication or API contract failures propagate immediately so
the failure is reported right away instead of being retried until timeout.

---

Nitpick comments:
In `@src/main/kotlin/com/redhat/devtools/gateway/devworkspace/DevWorkspaces.kt`:
- Line 287: The poll loop that runs every second is inefficiently re-allocating
a new DevWorkspaces wrapper instance on each iteration by calling
DevWorkspaces(client).get(namespace, name). Instead, call the get method
directly on the current DevWorkspaces instance to avoid unnecessary object
allocation in the tight polling loop.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: db7f3152-3a91-4cea-a95c-f524fa2261bd

📥 Commits

Reviewing files that changed from the base of the PR and between c8709c0 and ed78286.

📒 Files selected for processing (3)
  • src/main/kotlin/com/redhat/devtools/gateway/devworkspace/DevWorkspaceWatcher.kt
  • src/main/kotlin/com/redhat/devtools/gateway/devworkspace/DevWorkspaces.kt
  • src/main/kotlin/com/redhat/devtools/gateway/view/steps/DevSpacesWorkspacesStepView.kt
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/kotlin/com/redhat/devtools/gateway/view/steps/DevSpacesWorkspacesStepView.kt
  • src/main/kotlin/com/redhat/devtools/gateway/devworkspace/DevWorkspaceWatcher.kt

Signed-off-by: msivasubramaniaan <msivasub@redhat.com>
Signed-off-by: msivasubramaniaan <msivasub@redhat.com>
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.

2 participants