Skip to content

fix: enforce positive token list limits#11

Merged
smypmsa merged 2 commits intochainstacklabs:mainfrom
saudademjj:codex/fix-tokens-limit-min
Mar 17, 2026
Merged

fix: enforce positive token list limits#11
smypmsa merged 2 commits intochainstacklabs:mainfrom
saudademjj:codex/fix-tokens-limit-min

Conversation

@saudademjj
Copy link
Contributor

@saudademjj saudademjj commented Mar 17, 2026

Summary

  • add min=1 validation to all token listing --limit options
  • reject 0 and negative values before the command reaches token fetching
  • add command tests covering invalid limits for all five token subcommands

Closes #4

Testing

  • uv run pytest tests/test_commands/test_smoke.py -q
  • uv run ruff check src/ tests/
  • uv run pytest tests/ -q

Summary by CodeRabbit

  • Improvements

    • Token listing commands now enforce a minimum limit of 1; zero or negative values are rejected with clear error messages.
  • Tests

    • Added tests to verify limit validation across token listing and search commands, ensuring consistent CLI behavior.

@saudademjj saudademjj requested a review from smypmsa as a code owner March 17, 2026 11:59
@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b5f4a32b-342e-41da-8925-50060b91338b

📥 Commits

Reviewing files that changed from the base of the PR and between 9e81eb2 and dd9d7d4.

📒 Files selected for processing (2)
  • src/pumpfun_cli/commands/tokens.py
  • tests/test_commands/test_smoke.py

📝 Walkthrough

Walkthrough

Adds a minimum value validator (min=1) to the --limit option for five token-listing CLI commands and updates tests to assert that zero and negative limits are rejected by the CLI argument parser.

Changes

Cohort / File(s) Summary
Token Commands Validation
src/pumpfun_cli/commands/tokens.py
Added min=1 to the limit: int = typer.Option(...) parameter for trending(), new(), graduating(), the hidden top command (previously recommended), and search() to ensure CLI rejects 0/negative limits.
Token Limit Validation Tests
tests/test_commands/test_smoke.py
Added a parameterized test (test_tokens_limit_must_be_at_least_one) that runs the token-listing subcommands (trending, new, graduating, top/recommended, search) with --limit values "0" and "-1", expecting CLI parsing to fail (exit code 2) and report invalid --limit values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The decorator change (@app.command('top', hidden=True)) for the recommended command appears to be a UI/alias enhancement outside the scope of #4's core fix. Clarify whether the 'top' alias change is in scope for #4, or separate it into a dedicated PR to maintain focused commits.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding minimum value validation to enforce positive limits on token listing commands.
Description check ✅ Passed The description covers the main objective and testing approach, though it omits the 'Layers touched' section from the template.
Linked Issues check ✅ Passed The PR correctly implements all requirements from #4: adds min=1 validation to all five token listing commands and includes tests for invalid limits.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@saudademjj
Copy link
Contributor Author

Added a small follow-up to address the pre-merge warning: tokens top is now registered as a hidden compatibility alias for tokens recommended, and the invalid --limit test matrix now covers that alias as well. This keeps the current CLI surface intact while matching the issue wording that referenced top as the fifth token-listing command.

@smypmsa smypmsa merged commit 3460c98 into chainstacklabs:main Mar 17, 2026
6 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.

Add min=1 constraint to --limit on token listing commands

2 participants