Skip to content

fix(api): "command not found" error when running addPluginListener - #14132

Merged
lucasfernog merged 10 commits into
devfrom
fix/register-plugin-listener
Oct 6, 2025
Merged

fix(api): "command not found" error when running addPluginListener#14132
lucasfernog merged 10 commits into
devfrom
fix/register-plugin-listener

Conversation

@lucasfernog

Copy link
Copy Markdown
Member

the backend expects the command name to be in snake case

we've made this change already for check_permissions and request_permissions, but missed register_listener

the backend expects the command name to be in snake case

we've made this change already for check_permissions and request_permissions, but missed register_listener
@lucasfernog
lucasfernog requested a review from a team as a code owner August 31, 2025 20:11
@github-actions

github-actions Bot commented Aug 31, 2025

Copy link
Copy Markdown
Contributor

Package Changes Through bd253c6

There are 9 changes which include @tauri-apps/api with minor, tauri-cli with minor, tauri-utils with minor, tauri-runtime-wry with minor, tauri-runtime with minor, tauri with minor, tauri-bundler with minor, @tauri-apps/cli with minor, tauri-macros with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.8.0 2.9.0
tauri-utils 2.7.0 2.8.0
tauri-bundler 2.6.1 2.7.0
tauri-runtime 2.8.0 2.9.0
tauri-runtime-wry 2.8.1 2.9.0
tauri-codegen 2.4.0 2.4.1
tauri-macros 2.4.0 2.4.1
tauri-plugin 2.4.0 2.4.1
tauri-build 2.4.1 2.4.2
tauri 2.8.5 2.9.0
@tauri-apps/cli 2.8.4 2.9.0
tauri-cli 2.8.4 2.9.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@FabianLars

Copy link
Copy Markdown
Member

No we did not miss it, we reverted it because for some unknown reason snake case didn't work: #11423

@lucasfernog

Copy link
Copy Markdown
Member Author

oh ok i'll need to dig deeper

@FabianLars

Copy link
Copy Markdown
Member

good luck 😅 i hope you can find it. i couldn't make sense of it. especially since it appears to be a bit inconsistent at times.

@lucasfernog

Copy link
Copy Markdown
Member Author

well like someone once said, the whole permission validation is a bit.. messy, crazy flow

@Legend-Master Legend-Master left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Correct me if I'm wrong

  • On desktop, we match the ACL and the command by the exact command names
  • On mobile, we still use the exact command names when matching ACLs, but we transform the command calls to camelCase

heck::AsLowerCamelCase(message.command).to_string(),

And from the current casing conventions, registerListener seems to be an outlier? I know we can't change that in v2 or we break existing ones that uses the camelCase though

Comment thread crates/tauri/src/webview/mod.rs Outdated
&acl_origin,
)
.or_else(|| {
if request.cmd.chars().any(|c| c.is_uppercase()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I honestly don't like this, it means we now match the commands in different casing without formal documentation, and that's confusing, I'd rather use a try catch call in the addPluginListener function

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

maybe we just have a particular case for registerListener then? i don't really want to make two calls for a single command :/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

well i'll just go with your idea.. better than bloating the rust side with a lot of temp logic :(

@lucasfernog
lucasfernog merged commit 08bda64 into dev Oct 6, 2025
19 checks passed
@lucasfernog
lucasfernog deleted the fix/register-plugin-listener branch October 6, 2025 17:55
@chrox

chrox commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

We'd better reference tauri-apps/tauri#12486 in this PR to inform developers whose products currently rely on registerListener, so they can update their code accordingly and avoid potential breaking changes.

This is the error message in Tauri 2.9.* if we only allow registerListener as in Tauri 2.8.* and below:

Failed to setup TTS event listener: native-tts.register_listener not allowed. Command not found
setupEventListener | @ | page-ae56bef211a9a7b4.js:1

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.

4 participants