Skip to content

Conversation

@toothbrush
Copy link
Contributor

@toothbrush toothbrush commented Feb 5, 2026

Description

  • Consolidate the 3 spots we were parsing settings
  • Be strict - don't let things silently fail due to malformed JSON or unrecognised config keys

Note

Medium Risk
Touches core configuration IO and hook/runtime behavior; strict decoding may break users with previously-ignored/typoed config keys and cause commands/hooks to error until configs are fixed.

Overview
Settings loading/saving is consolidated into the settings package: cli/config.go, hook installation (strategy/hooks.go), push-session logic (strategy/push_common.go), and detailed status output (setup.go) now call settings.Load/Save/SaveLocal/LoadFromFile instead of re-parsing JSON in multiple places.

Settings JSON parsing is now strict: both base and local settings files reject unknown keys via DisallowUnknownFields, with new tests in cli/config_test.go and settings/settings_test.go covering the failure cases. The settings package also adds IsPushSessionsDisabled() helper and centralized file write logic using jsonutil.

Written by Cursor Bugbot for commit 2a4b60a. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings February 5, 2026 12:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR consolidates settings parsing into a dedicated settings package and implements strict JSON validation to prevent silent failures from malformed configuration or unrecognized keys.

Changes:

  • Introduced a new settings package with strict JSON parsing using DisallowUnknownFields() to reject unknown configuration keys
  • Refactored settings loading from 3 different locations (config.go, strategy/push_common.go, strategy/hooks.go) to use the centralized settings.Load() function
  • Maintained backwards compatibility by re-exporting types and constants from the cli package

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cmd/entire/cli/settings/settings.go New settings package with strict JSON parsing, consolidating settings loading/saving logic with DisallowUnknownFields() validation
cmd/entire/cli/settings/settings_test.go Tests verifying strict JSON parsing rejects unknown keys in both base and local settings files
cmd/entire/cli/config.go Refactored to delegate to settings package while maintaining backwards compatibility via re-exports
cmd/entire/cli/config_test.go Added tests for unknown key rejection in base and local settings files
cmd/entire/cli/setup.go Updated to use settings.LoadFromFile() for loading individual settings files in status display
cmd/entire/cli/strategy/push_common.go Simplified to use settings.Load() and IsPushSessionsDisabled() method instead of custom parsing
cmd/entire/cli/strategy/hooks.go Refactored isLocalDev() to use settings.Load() instead of custom JSON parsing

@toothbrush toothbrush marked this pull request as ready for review February 6, 2026 05:26
@toothbrush toothbrush requested a review from a team as a code owner February 6, 2026 05:26
toothbrush and others added 7 commits February 6, 2026 10:57
  1. loadFromFile - Now uses json.NewDecoder with DisallowUnknownFields() instead of json.Unmarshal
  2. mergeJSON - Added strict validation at the start that decodes into a temp struct with DisallowUnknownFields() before doing the field-by-field merge

  Also added settings_test.go with three tests:
  - TestLoad_RejectsUnknownKeys - verifies main settings file rejects unknown keys
  - TestLoad_AcceptsValidKeys - verifies all valid keys are accepted
  - TestLoad_LocalSettingsRejectsUnknownKeys - verifies local override file also rejects unknown keys

Entire-Checkpoint: c4a4c0bba140
Changes made:
  - Removed output_filter from test JSON and assertions (field was removed from struct)
  - Replaced os.Chdir() with t.Chdir() which handles cleanup automatically

Entire-Checkpoint: b703660e28ea
Previously, settings were parsed in three separate places:
- settings/settings.go (the dedicated package)
- config.go (duplicated EntireSettings struct and Load/Save logic)
- strategy/hooks.go and push_common.go (ad-hoc JSON parsing)

This consolidates all settings parsing into the settings package:

1. settings/settings.go now contains:
   - The canonical EntireSettings struct
   - Load(), Save(), SaveLocal(), LoadFromFile() functions
   - Helper methods: IsSummarizeEnabled(), IsMultiSessionWarningDisabled(),
     IsPushSessionsDisabled()

2. config.go now delegates to settings package:
   - EntireSettings is a type alias to settings.EntireSettings
   - LoadEntireSettings() calls settings.Load()
   - SaveEntireSettings() calls settings.Save()
   - Removed ~200 lines of duplicated parsing code

3. strategy/hooks.go:
   - isLocalDev() now uses settings.Load().LocalDev
   - Removed ad-hoc JSON parsing

4. strategy/push_common.go:
   - isPushSessionsDisabled() now uses settings.Load().IsPushSessionsDisabled()
   - Removed readPushSessionsFromFile() and 50+ lines of ad-hoc parsing

Benefits:
- Single place to update when adding new settings fields
- Consistent strict parsing (DisallowUnknownFields) everywhere
- Easier to maintain and test

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Entire-Checkpoint: d9e47174f862
@toothbrush toothbrush force-pushed the 20260205-strict-settings-parsing branch from 37fb3b2 to 36e0583 Compare February 6, 2026 05:30
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Entire-Checkpoint: 1b8e9b9a1c07
@toothbrush toothbrush merged commit 6ca4281 into main Feb 6, 2026
4 checks passed
@toothbrush toothbrush deleted the 20260205-strict-settings-parsing branch February 6, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants