feat: clear global overrides on Project Defaults reset [IDE-2149]#429
feat: clear global overrides on Project Defaults reset [IDE-2149]#429nick-y-snyk wants to merge 1 commit into
Conversation
Honor inbound global resets from the LS: when $/snyk.configuration sends
a global setting as {value:null, changed:true}, drop the persisted
preference value and clear explicit-change tracking, so the override is
not re-asserted on the next outbound sync/reconnect.
- SnykExtendedLanguageClient.persistGlobalSettings: on a null+changed
reset, removePref(prefKey) + clearExplicitlyChanged(prefKey) instead of
skipping; non-null persist behavior unchanged.
- Preferences.removePref: remove a persisted value (fall back to default).
- HTMLSettingsPreferencePage: form-save null path also removes the
persisted value so the next outbound sends changed:false.
- InMemoryPreferenceStore (test fake): implement remove.
- Tests: inbound null reset clears value + explicit-changed; null+
changed:false is ignored; re-push guard in LsConfigurationUpdaterTest
(changed:false after reset).
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
PR Reviewer Guide 🔍
|
| // Global reset: LS Unset the user:global override and pushed back | ||
| // {value:null, changed:true}. Drop the persisted override and clear | ||
| // explicit-changed tracking so we don't re-assert it on the next sync. | ||
| prefs.removePref(registryEntry.prefKey); |
There was a problem hiding this comment.
Should Fix — two reset paths can be silently undone. This is the core reset logic; two interactions can defeat it:
-
Severity-filter partial reset re-asserts siblings. The four severity-filter keys share an OR'd outbound
changedflag inLsConfigurationUpdater/LsSettingsRegistry. If the LS pushes{value:null, changed:true}for only a subset of the four, this loop clears just those keys, but the un-reset siblings keep their persisted value and explicit-changed entry — and because the outboundchangedis OR'd across the co-key group, all four are still sentchanged=trueon the next sync, re-asserting the overrides the reset was meant to clear. Worth confirming what subset the LS can emit, and handling the co-key group atomically if it can send a strict subset. -
Env-var reseed resurrects reset endpoint/org.
ENDPOINT/ORGANIZATIONare non-encrypted registry entries reachable by this reset path, but thePreferencesconstructor unconditionally re-seeds them fromSNYK_API/SNYK_ORGon every restart. So a reset of those keys is silently undone on the next plugin start when those env vars are set.
— AI review
| var setting = entry.getValue(); | ||
| if (setting.getValue() != null) { | ||
| prefs.store(registryEntry.prefKey, registryEntry.inboundDeserializer.apply(setting.getValue())); | ||
| } else if (Boolean.TRUE.equals(setting.getChanged())) { |
There was a problem hiding this comment.
Suggestion — code and comment disagree about the trigger. The branch fires purely on value==null && changed==true, but the comment (and removePref's javadoc) describe this as an "org-scope global" reset. ConfigSetting.originScope is deserialized from the wire yet never read here, so any {value:null, changed:true} — regardless of scope — performs the destructive override removal. Either gate on "org".equals(setting.getOriginScope()), or drop the "org-scope" wording so the code and its docs agree about what triggers the removal. — AI review
Verdict: clean, surgical, well-tested change. The shared Should Fix (inline)
Suggestions
— AI review |
What
Implements the Eclipse side of IDE-2149 — global ("Project Defaults") reset overrides in the HTML settings page (sibling of the per-folder reset, IDE-1945).
Honors inbound global resets from the LS: when
$/snyk.configurationsends a global setting as{value:null, changed:true}, Eclipse drops the persisted preference value and clears explicit-change tracking, so the override is not re-asserted on the next outbound sync/reconnect.Changes
SnykExtendedLanguageClient.persistGlobalSettings— on anull+changed:truereset,removePref(prefKey)+clearExplicitlyChanged(prefKey)instead of skipping; non-null persist behavior unchanged. (Inbound still never marks settings as explicitly changed.)Preferences.removePref— remove a persisted value (falls back to default).HTMLSettingsPreferencePage— form-save null path also removes the persisted value so the next outbound sendschanged:false.InMemoryPreferenceStore(test fake) — implementremove.null+changed:falseignored; re-push guard inLsConfigurationUpdaterTest(changed:falseafter reset).Notes
SnykExtendedLanguageClientTest,LsConfigurationUpdaterTest) could not run locally — the inline mock-maker fails under JDK 21 inside the Tycho/Equinox surefire runtime. They will run in CI. PMD and compilation are clean locally; non-mock tests (HTMLSettingsPreferencePageTest25/25,PreferencesTest,FolderConfigSettingsTest) pass.🤖 Generated with Claude Code