Skip to content

protocol: Hide unimplemented channel commands - #104

Merged
jodal merged 2 commits into
mopidy:mainfrom
snowyukitty:fix/hide-unimplemented-channel-commands
Oct 30, 2026
Merged

jodal merged 2 commits into
mopidy:mainfrom
snowyukitty:fix/hide-unimplemented-channel-commands

Conversation

@snowyukitty

@snowyukitty snowyukitty commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

The channel commands are advertised even though their handlers always return Not implemented. Clients such as MPD_sima can interpret this as support for messaging.

Set list_command=False on the five channel handlers, with a reminder to remove that flag when each command is implemented. This hides them from both commands and notcommands, while retaining their registration and direct-call behavior.

Keep one focused regression for capability discovery. The extra authentication/direct-call tests were removed as requested in review.

Validation from the repository root, with Python 3.13.5 and Mopidy 4.0.2:

  • pytest tests -q --cov: 808 passed, 1 skipped (10 subtests passed).
  • ruff check ., ruff format --check ., pyright src, and python -m build --no-isolation pass.
  • The retained discovery regression fails against the original handlers (five failing subtests).
  • A separate loopback TCP check using the production MpdFrontend confirms the discovery change and unchanged direct-call ACK responses with and without a password. Native dummy backends supply the core fixtures; audio playback was not exercised.

Fixes #19

Comment thread src/mopidy_mpd/protocol/channels.py Outdated


@protocol.commands.add("subscribe")
@protocol.commands.add("subscribe", list_command=False)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make all of these formatted like this, so we have a chance of remembering to start listing the commands again when/if we implement them?

Suggested change
@protocol.commands.add("subscribe", list_command=False)
@protocol.commands.add(
"subscribe",
list_command=False, # Remove when implementing command
)

Comment thread tests/protocol/test_reflection.py Outdated
Comment on lines +94 to +127
def test_unimplemented_channels_are_not_advertised_before_or_after_login(self):
for authenticated in (False, True):
if authenticated:
self.send_request('password "topsecret"')
self.assertEqualResponse("OK")
for request in ("commands", "notcommands"):
self.send_request(request)
for name in CHANNEL_REQUESTS:
with self.subTest(
authenticated=authenticated, request=request, command=name
):
self.assertNotInResponse(f"command: {name}")
self.assertInResponse("OK")
if (request == "commands") == authenticated:
self.assertInResponse("command: play")
self.assertInResponse("command: status")

def test_unlisted_channels_keep_their_authentication_and_error_responses(self):
for authenticated in (False, True):
if authenticated:
self.send_request('password "topsecret"')
self.assertEqualResponse("OK")
for name, request in CHANNEL_REQUESTS.items():
with self.subTest(authenticated=authenticated, command=name):
self.send_request(request)
if authenticated:
self.assertEqualResponse(
f"ACK [0@0] {{{name}}} Not implemented"
)
else:
self.assertEqualResponse(
f"ACK [4@0] {{{name}}} "
f'you don\'t have permission for "{name}"'
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel these tests are a bit too much. Tests needs to be maintained too. With these gone, CHANNEL_REQUESTS can be inlined as a list of five commands.

@snowyukitty

Copy link
Copy Markdown
Contributor Author

Updated in 66ab85a:

  • Expanded all five decorators and added # Remove when implementing command beside list_command=False.
  • Removed the two extra tests in ReflectionWhenNotAuthedTest and inlined the five command names in the retained discovery regression.

From the repository root, pytest tests -q --cov passed with 808 passed, 1 skipped and 10 subtests passed on Python 3.13.5 / Mopidy 4.0.2. Ruff lint/format checks, pyright src and wheel/sdist builds also passed. The PR description now reflects the reduced test scope and current results.

@jodal
jodal merged commit 9e09d5e into mopidy:main Oct 30, 2026
10 checks passed
@jodal

jodal commented Oct 30, 2026

Copy link
Copy Markdown
Member

Thanks!

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.

MPD: Wrongly annonces support for channels

2 participants