JOJ0 / synadm

Command line admin tool for Synapse (the Matrix reference homeserver)
https://synadm.readthedocs.io
GNU General Public License v3.0
186 stars 25 forks source link

regtok delete is broken #110

Closed andreiz closed 1 year ago

andreiz commented 1 year ago

I'm using 0.41.2 (git clone of the repo). Running synadm regtok delete <token> results in:

Traceback (most recent call last):
  File "/root/code/synadm/.venv/bin/synadm", line 33, in <module>
    sys.exit(load_entry_point('synadm', 'console_scripts', 'synadm')())
  File "/root/code/synadm/.venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/root/code/synadm/.venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/root/code/synadm/.venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/root/code/synadm/.venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/root/code/synadm/.venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/root/code/synadm/.venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/root/code/synadm/.venv/lib/python3.10/site-packages/click/decorators.py", line 38, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/root/code/synadm/synadm/cli/regtok.py", line 146, in regtok_delete
    response = helper.api.regtok_delete(token)
  File "/root/code/synadm/synadm/api.py", line 1261, in regtok_delete
    return self.query("delete", "v1/registration_tokens/{token}",
  File "/root/code/synadm/synadm/api.py", line 114, in query
    urlpart = urlpart.format(*args, **kwargs)
KeyError: 'token'

The rest of the commands seem to work.

JacksonChen666 commented 1 year ago

can you post the output of "git describe"? (or "git rev-parse HEAD" if that doesn't work)

andreiz commented 1 year ago
# git describe
v0.41.2-11-g11c7db7
JacksonChen666 commented 1 year ago

Hmmm, can't reproduce...

$ synadm regtok delete "qnv~whje8nfi_RJN"
Registration token successfully deleted.

@andreiz What was the full command that you ran?

andreiz commented 1 year ago

`$ synadm regtok delete "mytoken"

Nothing out of the ordinary.

The token seems to persist in the context.params at least until here:

File "/root/code/synadm/.venv/lib/python3.10/site-packages/click/core.py", line 1658

For what it's worth, it pulled in click-8.1.3 when I ran setup.py develop

JacksonChen666 commented 1 year ago

I can reproduce, bisect says first bad commit is 68749391d6a291d2fac229214f59924189c775ac.

I'll continue to look into this, thanks for the report @andreiz.

JacksonChen666 commented 1 year ago

Issue: query function accepts token as an arg, it doesn't go into **kwargs so KeyError.

May need to review other things that use conflicting keywords.

Workarounds: ¯\_(ツ)_/¯

JacksonChen666 commented 1 year ago

Fix available in the fix-regtok-delete branch while I wait for JOJ0 to approve the PR.

JOJ0 commented 1 year ago

Thanks @andreiz for that catch and thanks @JacksonChen666 for fixing :+1: PR approved.