Skip to content

Allow FT._debug to use when client is admin#914

Open
bandalgomsu wants to merge 1 commit intovalkey-io:mainfrom
bandalgomsu:gh-779
Open

Allow FT._debug to use when client is admin#914
bandalgomsu wants to merge 1 commit intovalkey-io:mainfrom
bandalgomsu:gh-779

Conversation

@bandalgomsu
Copy link
Contributor

Implement an admin check function and, through it, allow the use of FT._debug if the user is an admin.

issue : #779

@bandalgomsu bandalgomsu force-pushed the gh-779 branch 2 times, most recently from 0d96946 to e3289c8 Compare March 17, 2026 14:03
Signed-off-by: Su Ko <rhtn1128@gmail.com>
@@ -347,7 +348,7 @@ absl::Status HelpCmd(ValkeyModuleCtx *ctx, vmsdk::ArgsIterator &itr) {
absl::Status FTDebugCmd(ValkeyModuleCtx *ctx, ValkeyModuleString **argv,
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a comment here explaining when this command is allowed to be used?

Comment on lines +415 to +418
auto reply = vmsdk::UniquePtrValkeyCallReply(
ValkeyModule_Call(ctx, "ACL", "cs3", "GETUSER", username.get()));
VMSDK_ASSIGN_OR_RETURN(auto acl_views, GetAclViewFromCallReply(reply.get()));
for (const auto &acl_view : acl_views) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we instead make use of this API?

ValkeyModule_GetModuleUserACLString

https://valkey.io/topics/modules-api-ref/#ValkeyModule_GetModuleUserACLString

We should not need to execute ACL commands since we have these Module APIs

Copy link
Member

Choose a reason for hiding this comment

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

Also, all of this can be skipped if we follow: #914 (comment)

int argc) {
std::string msg;
if (!vmsdk::config::IsDebugModeEnabled()) {
if (!vmsdk::config::IsDebugModeEnabled() && !AclAdminCheck(ctx).ok()) {
Copy link
Member

@KarthikSubbarao KarthikSubbarao Mar 19, 2026

Choose a reason for hiding this comment

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

I can agree that this is a way to allow a non-breaking change. ie, we continue to allow the command to be used by all clients in DebugModeEnabled whether they are admin or not.

But I don't understand why the FT.DEBUG command was not flagged as "ADMIN" to begin with. @murphyjacob4 , do you have context on this?

The DEBUG command in the valkey core is flagged as admin-only. See: https://valkey.io/commands/debug/
Non-admin clients cannot use it.

If we flagged the FT.DEBUG command as "admin" in the command flags we use to register it, we would not need to add these custom checks.

If we don't want this to be a breaking change, we can continue with what you have in this PR

Copy link
Member

Choose a reason for hiding this comment

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

Update: Checked with Jacob, the admin command flag was likely just missed when FT.DEBUG was created.

@bandalgomsu , so let's just add the admin and dangerous command flags to the FT.DEBUG command registration. Then, we can skip the custom code for ACL checks because the valkey core will handle it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks more consistent and simple. thus I agree with that 👍
could you please confirm if my understanding is correct?

  1. set the ACL categories of FT._DEBUG to ADMIN, DANGEROUS, and SLOW (Should Search be included as well ??)
  2. delete the debug mode check logic.

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.

2 participants