tmux-python / tmux-python/libtmux-mcp

BOM and `--pr` input handling in mcp_swap

Open Beginner friendly
#121 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
13
Forks
0
Avg merge
13h 52m
Merged PRs (30d)
4

Description

Summary

Two small input-handling defects at the edges of scripts/mcp_swap.py. Filed together because both are one-line fixes in argument/decode handling; split if you would rather track them apart.

A UTF-8 BOM makes a config unswappable. Configs are read with a plain .decode(), so a byte-order mark — which editors on Windows still add — fails the parse for every CLI. It fails closed with a readable message, so this is an annoyance rather than a risk, but utf-8-sig would decode it.

[cursor] Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)

--pr accepts values that are not the number the user typed. The value goes through bare int(), which accepts underscore separators, a leading +, surrounding whitespace, and non-ASCII digits. --pr 1_0 silently swaps to PR 10:

$ run use-local --repo "$PWD" --cli cursor --pr '1_0' --no-preflight
PR #10

--pr '٥' (Arabic-Indic five) is accepted the same way.

Expected

A BOM decodes rather than failing the parse. --pr rejects anything that is not a plain run of ASCII digits, so a typo is an error instead of a different pull request.

References

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in scripts/mcp_swap.py at load_config around lines 368-378 and _pr_number around lines 246-258. Verify that UTF-8 BOM input decodes successfully and that --pr accepts only plain ASCII digits, rejecting separators, signs, whitespace, and non-ASCII digits.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.