Skip to content

fix(configsvc): deep-copy tool-filter slices in Snapshot.Clone (+ regression guard)#479

Merged
Dumbris merged 2 commits into
mainfrom
fix/config-file-disabled-tools-runtime-gap
May 18, 2026
Merged

fix(configsvc): deep-copy tool-filter slices in Snapshot.Clone (+ regression guard)#479
Dumbris merged 2 commits into
mainfrom
fix/config-file-disabled-tools-runtime-gap

Conversation

@Dumbris
Copy link
Copy Markdown
Member

@Dumbris Dumbris commented May 18, 2026

Follow-up to the spec-049 review item "config-file disabled_tools→runtime gap".

TL;DR — the reported gap is not a code bug

Systematic debugging (every boundary, deterministic repro) proved config-file enabled_tools/disabled_tools do reach IsToolConfigDenied through the full production path: file parse → LoadFromFileruntime.New (ConfigService) → LoadConfiguredServers (config→storage) → SaveConfiguration (storage→ConfigService + file rewrite). The original manual observation was a test-environment artifact (reused /tmp data-dir while mcpproxy's own SaveConfiguration() rewrites the config file, plus the hot-reload watcher → indeterminate effective config at the echo call).

What this PR actually ships

  1. Real latent defect fixed: configsvc.Snapshot.Clone() deep-copied Args/Headers/Env/OAuth/Isolation but shallow-aliased the feat(config): layered config tool filter — config_denied over user toggles #468 EnabledTools/DisabledTools slices (clonedSrv := *srv). Not data loss, but an immutability violation — mutating a cloned config's filter corrupts the shared backing array. Now deep-copied.
  2. TestSnapshotClone_DeepCopiesToolFilters — aliasing regression.
  3. TestConfigFileToolFilter_ReachesRuntime — permanent deterministic guard for the exact concern, exercising the full file→runtime path incl. the SaveConfiguration file rewrite.
  4. Corrects the spec-049 quickstart.md note that wrongly recorded this as a confirmed feat(config): layered config tool filter — config_denied over user toggles #468 gap.

No behavior change to the happy path; no storage/enforcement change.

Related #468

Investigation of the reported 'config-file disabled_tools does not reach
runtime' concern found NO reproducible code bug: every boundary (file
parse, storage Save/Get/List, and the full path
parse->New->LoadConfiguredServers->SaveConfiguration->IsToolConfigDenied)
provably preserves enabled_tools/disabled_tools. The original manual
observation was a test-environment artifact (reused /tmp data-dir while
SaveConfiguration rewrites the config file + hot-reload watcher).

The investigation did surface one real latent defect: Snapshot.Clone()
deep-copied Args/Headers/Env/OAuth/Isolation but shallow-aliased the
spec-049 EnabledTools/DisabledTools slices via 'clonedSrv := *srv'. Not
data loss (reads see the aliased value) but an immutability violation:
mutating a cloned config's filter would corrupt the shared backing array.

- Deep-copy EnabledTools/DisabledTools in Snapshot.Clone
- TestSnapshotClone_DeepCopiesToolFilters (aliasing regression)
- TestConfigFileToolFilter_ReachesRuntime (permanent full-path guard)
- correct the spec-049 quickstart note (no #468 gap exists)

Related #468
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 18, 2026

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4d9536b
Status: ✅  Deploy successful!
Preview URL: https://d27fbd61.mcpproxy-docs.pages.dev
Branch Preview URL: https://fix-config-file-disabled-too.mcpproxy-docs.pages.dev

View logs

The first revision string-interpolated t.TempDir() into a JSON literal;
on windows-amd64 the backslash path produced invalid JSON, failing the
test (caught by the Build Binaries windows job). Marshal the config via
encoding/json so the path is escaped on every OS.

Related #468
@github-actions
Copy link
Copy Markdown

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/config-file-disabled-tools-runtime-gap

Available Artifacts

  • archive-darwin-amd64 (26 MB)
  • archive-darwin-arm64 (23 MB)
  • archive-linux-amd64 (15 MB)
  • archive-linux-arm64 (13 MB)
  • archive-windows-amd64 (26 MB)
  • archive-windows-arm64 (23 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (20 MB)
  • installer-dmg-darwin-arm64 (18 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 26044970725 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@Dumbris Dumbris merged commit 3cafa5a into main May 18, 2026
23 checks passed
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.

1 participant