Skip to content

fix: critical bugs in exec pipeline, map cache, and MCP install#4

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-1134
Draft

fix: critical bugs in exec pipeline, map cache, and MCP install#4
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-1134

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented Jun 7, 2026

Summary

Weekly critical bug investigation found and fixed 4 high-severity issues in recent code paths.

1. UTF-8 panic in ctx exec filters (crash)

  • Impact: ctx exec git blame (and aws/docker/kubectl filters with truncate_lines_at) could panic when a line contained multi-byte UTF-8 and the byte cut landed inside a character.
  • Root cause: truncate_lines sliced at byte index without checking char boundaries.
  • Fix: Truncate at the nearest valid UTF-8 boundary before slicing.

2. Stale ctx map cache on dirty repos (silent wrong context)

  • Impact: After editing uncommitted files, ctx map could return a stale cached map from before the edits — agents receive outdated signatures/structure.
  • Root cause: git_commit_key for dirty repos hashed only the directory path (first 32 bytes), not working-tree state.
  • Fix: Include git status --porcelain output in the dirty cache key.

3. MCP config overwrite on install (data loss)

  • Impact: ctx install --agent claude-desktop (or claude-code) overwrote an existing mcpServers.ctx entry if it lacked the _installer: "ctx" marker — permanent loss of user config.
  • Root cause: insert_mcp_server only no-op'd for ctx-marked entries.
  • Fix: Skip insertion when any same-named entry already exists.

4. Failed commands masked as success in ctx exec (agent misinformation)

  • Impact: git pull auth/network failures could return stdout "ok" while exit code was non-zero — agents may treat the operation as successful.
  • Root cause: on_empty fallback applied regardless of subprocess exit code.
  • Fix: Only apply on_empty when exit_code == 0.

Validation

  • Added unit tests for each fix
  • cargo test — all passing
  • cargo clippy --all-targets --all-features -- -D warnings — clean
Open in Web View Automation 

- truncate_lines: respect UTF-8 char boundaries (prevents panic in git blame/aws logs)
- git_commit_key: include porcelain status for dirty repos (fixes stale ctx map cache)
- insert_mcp_server: skip overwrite when user-owned mcpServers.ctx exists
- run_proxy_capture: suppress on_empty fallback when exit code != 0

Co-authored-by: Jaime Basso <JaimeJunr@users.noreply.github.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.

1 participant