From 819aa2c0d7860e8bba0ca39daf25e3beaea6cef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=84=82=CA=8F=E1=B4=87=E1=B4=85=20=F0=9F=84=B0=CA=99?= =?UTF-8?q?=E1=B4=85=E1=B4=9C=CA=9F=20=F0=9F=84=B0=E1=B4=8D=E1=B4=80?= =?UTF-8?q?=F0=9F=84=9D=20=E2=9C=A7?= Date: Wed, 18 Mar 2026 15:42:23 +0530 Subject: [PATCH] fix: validate config keys against known set in config set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 🄂ʏᴇᴅ 🄰ʙᴅᴜʟ 🄰ᴍᴀ🄝 ✧ --- src/pumpfun_cli/commands/config.py | 8 ++++++++ tests/test_commands/test_config_cmd.py | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/src/pumpfun_cli/commands/config.py b/src/pumpfun_cli/commands/config.py index 4723fc1..6403803 100644 --- a/src/pumpfun_cli/commands/config.py +++ b/src/pumpfun_cli/commands/config.py @@ -18,9 +18,17 @@ def _config_callback(ctx: typer.Context): raise SystemExit(0) +KNOWN_KEYS = {"rpc", "keyfile", "priority_fee", "compute_units"} + + @app.command("set") def config_set(ctx: typer.Context, key: str, value: str): """Set a config value.""" + if key not in KNOWN_KEYS: + error( + f"Unknown config key: {key}", + hint=f"Valid keys: {', '.join(sorted(KNOWN_KEYS))}", + ) save_config_value(key, value) json_mode = ctx.obj.json_mode if ctx.obj else False if not render({"key": key, "value": value, "status": "saved"}, json_mode): diff --git a/tests/test_commands/test_config_cmd.py b/tests/test_commands/test_config_cmd.py index f2a3b41..fbb7bb4 100644 --- a/tests/test_commands/test_config_cmd.py +++ b/tests/test_commands/test_config_cmd.py @@ -80,3 +80,12 @@ def test_config_get_json_trailing(tmp_path, monkeypatch): assert result.exit_code == 0 data = json.loads(result.output) assert data == {"key": "rpc", "value": "https://example.com"} + + +def test_config_set_unknown_key(tmp_path, monkeypatch): + """config set rejects unknown config keys.""" + monkeypatch.setenv("XDG_CONFIG_HOME", str(tmp_path)) + result = runner.invoke(app, ["config", "set", "rpcc", "https://example.com"]) + assert result.exit_code != 0 + assert "unknown config key" in result.output.lower() + assert "valid keys" in result.output.lower()