SpotAPI icon indicating copy to clipboard operation
SpotAPI copied to clipboard

CLI: reject invalid player seek and volume values before connecting

Open Aran404 opened this issue 2 weeks ago • 3 comments

Problem

The Python player API correctly rejects negative seek positions and volume values outside 0–100. The CLI currently parses both as unrestricted integers, so obviously invalid input can reach account/session setup before producing an error.

Proposed change

Validate these values during argument parsing:

  • spotapi player seek MILLISECONDS: integer greater than or equal to zero.
  • spotapi player volume PERCENT: integer from zero through 100.

Acceptance criteria

  • [ ] Invalid values fail through argparse with a clear range message and exit status 2.
  • [ ] Invalid input is rejected before reading account state or opening a Spotify connection.
  • [ ] Boundary values 0 and 100 remain valid where applicable.
  • [ ] Existing valid commands retain their current behavior.
  • [ ] Offline tests cover negative seek, volume below zero, volume above 100, and boundaries.

Scope

Keep validation helpers small and local to the CLI. The existing validation inside Player.seek() and Player.volume() must remain as the library-level safety boundary.

Comment before starting so duplicate work can be avoided.

Aran404 avatar Nov 14 '26 15:11 Aran404

Picking this up: I'll add argparse type validators for player seek (integer >= 0 ms) and player volume (integer 0–100), mirroring the existing library checks in Player.seek() / Player.volume() and leaving those untouched. Offline CLI tests will cover negative seek, volume below 0, volume above 100, and the 0/100 boundaries, including that invalid input exits with status 2 before any session or connection is opened.

bfs2021 avatar Nov 14 '26 15:11 bfs2021

Picking this up: I'll add argparse type validators for player seek (integer >= 0 ms) and player volume (integer 0–100), mirroring the existing library checks in Player.seek() / Player.volume() and leaving those untouched. Offline CLI tests will cover negative seek, volume below 0, volume above 100, and the 0/100 boundaries, including that invalid input exits with status 2 before any session or connection is opened.

Sure, follow CONTRIBUTING.md please.

Aran404 avatar Nov 14 '26 23:11 Aran404

Verified and fixed on main. Invalid seek/volume values fail during argument parsing with exit code 2, before connecting. Added explicit tests for seek 0 and volume 0/100 in 7ec4932. The CLI and player tests pass (90 tests).

Closing as completed. This is available from main pending the next PyPI release.

Aran404 avatar Nov 18 '26 00:11 Aran404