Skip to content

fix(dashboard): preserve disabled/hidden state on MarketplacePanel reconciliation#2176

Merged
kvaps merged 1 commit intomainfrom
fix/marketplace-preserve-disabled-hidden
Mar 10, 2026
Merged

fix(dashboard): preserve disabled/hidden state on MarketplacePanel reconciliation#2176
kvaps merged 1 commit intomainfrom
fix/marketplace-preserve-disabled-hidden

Conversation

@IvanHunters
Copy link
Collaborator

@IvanHunters IvanHunters commented Mar 9, 2026

Summary

  • Fix "Disabling features from menu and marketplace is not working" by preserving user-set disabled and hidden values during controller reconciliation
  • The controller was hardcoding disabled=false and hidden=false on every reconcile loop, overwriting any changes made through the dashboard UI

Test plan

  • Disable a service from the dashboard marketplace panel
  • Verify the service stays disabled after controller reconciliation
  • Hide a service from the dashboard menu
  • Verify the service stays hidden after controller reconciliation
  • Create a new ApplicationDefinition and verify its MarketplacePanel defaults to disabled=false, hidden=false

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where user-configured "disabled" and "hidden" settings in the marketplace panel could be reset during updates. These preferences are now preserved when the panel is created or updated, and the system avoids applying unnecessary configuration changes when values haven't actually changed.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the dashboard controller where user-configured disabled and hidden states for marketplace panels were being reset to their default false values upon reconciliation. The changes ensure that the controller now correctly reads and applies existing user preferences, preventing unintended re-enabling or unhiding of services and improving the stability of dashboard configurations.

Highlights

  • Bug Fix: Resolved an issue where disabling features from the dashboard menu and marketplace was not persistent, as the controller was overwriting user-set disabled and hidden states.
  • State Preservation: Implemented logic to preserve user-defined disabled and hidden values during the controller's reconciliation process for MarketplacePanel resources.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • internal/controller/dashboard/marketplacepanel.go
    • Refactored the ensureMarketplacePanel function to move the specMap creation inside the CreateOrUpdate callback.
    • Added logic to unmarshal the existing mp.Spec.Raw to retrieve and preserve the current disabled and hidden boolean values.
    • Updated the specMap construction to use the preserved disabled and hidden values instead of hardcoding them to false.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 43380f54-e9c7-4db6-991b-12d3469b12ba

📥 Commits

Reviewing files that changed from the base of the PR and between eab121c and e69efd8.

📒 Files selected for processing (1)
  • internal/controller/dashboard/marketplacepanel.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/controller/dashboard/marketplacepanel.go

📝 Walkthrough

Walkthrough

Refactors the MarketplacePanel controller to construct the ArbitrarySpec inside the CreateOrUpdate callback, reading and preserving existing disabled and hidden values from MarketplacePanel.Spec.Raw, and only updating the spec when the new JSON differs from the current one. Early deletion and ownership/label logic unchanged.

Changes

Cohort / File(s) Summary
MarketplacePanel Spec Preservation
internal/controller/dashboard/marketplacepanel.go
Move spec construction into the CreateOrUpdate callback; decode existing MarketplacePanel.Spec.Raw to preserve disabled/hidden booleans (default false if absent); only set ArbitrarySpec when new JSON differs from the current one; minor control-flow/variable scope adjustments.

Sequence Diagram(s)

sequenceDiagram
  participant Reconciler as Reconciler (controller)
  participant API as Kubernetes API
  participant Resource as MarketplacePanel resource

  Reconciler->>API: Get existing MarketplacePanel
  API-->>Reconciler: existing resource (may include Spec.Raw)
  Reconciler->>Reconciler: decode Spec.Raw -> extract disabled/hidden (default false)
  Reconciler->>Reconciler: build specMap including preserved values
  Reconciler->>API: CreateOrUpdate MarketplacePanel with new ArbitrarySpec (only if JSON differs)
  API-->>Reconciler: result (created/updated/no-op)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I nibble on bytes in moonlit rows,
I find the bits that memory knows;
I tuck away hidden, and disabled too,
Only change when the new is true. 🐇✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: preserving disabled/hidden state during MarketplacePanel reconciliation, which directly addresses the core issue described in the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/marketplace-preserve-disabled-hidden

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.

@IvanHunters IvanHunters marked this pull request as ready for review March 9, 2026 10:59
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Mar 9, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request correctly addresses an issue where disabled and hidden states on MarketplacePanel resources were being overwritten during reconciliation. The change preserves these user-set values by reading them from the existing resource before constructing the new spec. The implementation is sound. I have one suggestion to improve observability by logging an error if parsing the existing spec fails, which would help in debugging cases where the state might be unexpectedly reset.

Comment on lines +83 to +90
if err := json.Unmarshal(mp.Spec.Raw, &existing); err == nil {
if v, ok := existing["disabled"].(bool); ok {
disabled = v
}
if v, ok := existing["hidden"].(bool); ok {
hidden = v
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The error from json.Unmarshal is silently ignored. While falling back to default values is a reasonable strategy if the existing spec is malformed, logging the error would provide valuable information for debugging, especially if user-configured disabled or hidden states are unexpectedly reset.

			if err := json.Unmarshal(mp.Spec.Raw, &existing); err != nil {
				logger.Info("Failed to unmarshal existing MarketplacePanel spec, using default disabled/hidden values", "name", mp.Name, "error", err)
			} else {
				if v, ok := existing["disabled"].(bool); ok {
					disabled = v
				}
				if v, ok := existing["hidden"].(bool); ok {
					hidden = v
				}
			}

Copy link
Contributor

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

🧹 Nitpick comments (1)
internal/controller/dashboard/marketplacepanel.go (1)

78-118: Please lock this in with a reconciliation regression test.

This behavior now depends on two subtle paths: preserving existing booleans from Spec.Raw on update, and defaulting both to false on create. A focused controller test for both cases would help prevent a future refactor from reintroducing the overwrite.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/controller/dashboard/marketplacepanel.go` around lines 78 - 118, Add
a reconciliation regression test that covers both create and update paths for
preserving the "disabled" and "hidden" booleans: simulate creating a
MarketplacePanel (use the same controller reconcile entrypoint used in tests)
and assert the stored mp.Spec.JSON (ArbitrarySpec/JSON.Raw) contains "disabled":
false and "hidden": false by default; then simulate an update where mp.Spec.Raw
contains {"disabled": true, "hidden": true}, run the reconcile logic so the code
path that reads mp.Spec.Raw and builds specMap (the logic that sets
disabled/hidden and constructs newSpec/ArbitrarySpec and calls
compareArbitrarySpecs) runs, and assert the reconciled resource preserves those
true values rather than overwriting them. Ensure the test exercises the
compareArbitrarySpecs branch that skips assignment when specs are equal and
fails if the booleans are lost.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/controller/dashboard/marketplacepanel.go`:
- Around line 78-118: Add a reconciliation regression test that covers both
create and update paths for preserving the "disabled" and "hidden" booleans:
simulate creating a MarketplacePanel (use the same controller reconcile
entrypoint used in tests) and assert the stored mp.Spec.JSON
(ArbitrarySpec/JSON.Raw) contains "disabled": false and "hidden": false by
default; then simulate an update where mp.Spec.Raw contains {"disabled": true,
"hidden": true}, run the reconcile logic so the code path that reads mp.Spec.Raw
and builds specMap (the logic that sets disabled/hidden and constructs
newSpec/ArbitrarySpec and calls compareArbitrarySpecs) runs, and assert the
reconciled resource preserves those true values rather than overwriting them.
Ensure the test exercises the compareArbitrarySpecs branch that skips assignment
when specs are equal and fails if the booleans are lost.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a938bd3f-cb7f-45e2-adc0-c4839c92cf13

📥 Commits

Reviewing files that changed from the base of the PR and between adacd44 and eab121c.

📒 Files selected for processing (1)
  • internal/controller/dashboard/marketplacepanel.go

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 9, 2026
…conciliation

The controller was hardcoding disabled=false and hidden=false on every
reconciliation, overwriting any user changes made through the dashboard
UI. Move spec building inside the CreateOrUpdate mutate function to read
and preserve current disabled/hidden values from the existing resource.

Signed-off-by: IvanHunters <[email protected]>
@kvaps kvaps force-pushed the fix/marketplace-preserve-disabled-hidden branch from eab121c to e69efd8 Compare March 10, 2026 11:41
@kvaps kvaps added backport Should change be backported on previus release backport-previous labels Mar 10, 2026
@kvaps kvaps merged commit 4b9c64c into main Mar 10, 2026
8 of 9 checks passed
@kvaps kvaps deleted the fix/marketplace-preserve-disabled-hidden branch March 10, 2026 16:48
@github-actions
Copy link

@github-actions
Copy link

kvaps added a commit that referenced this pull request Mar 10, 2026
… on MarketplacePanel reconciliation (#2202)

# Description
Backport of #2176 to `release-1.0`.
kvaps added a commit that referenced this pull request Mar 10, 2026
… on MarketplacePanel reconciliation (#2201)

# Description
Backport of #2176 to `release-1.1`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Should change be backported on previus release backport-previous bug Something isn't working lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants