Skip to content

Malformed markdown causes espanso to panic #759

Closed

Description

@KyleSnodgrass

Hello, I've been using your application for a little bit now and I've grown very very attached to it. It's pretty great. I just started having this issue yesterday with no apparent catalyst.

When I run "espanso start"
I get:

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/markdown-0.3.0/src/parser/block/unordered_list.rs:84:44
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Then when I run: "RUST_BACKTRACE=1RUST_BACKTRACE=1 espanso"
I get:

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/markdown-0.3.0/src/parser/block/unordered_list.rs:84:44
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: markdown::parser::block::unordered_list::parse_unordered_list
   4: markdown::parser::block::parse_blocks
   5: markdown::to_html
   6: <espanso::matcher::Match as serde::de::Deserialize>::deserialize
   7: <serde_yaml::de::SeqAccess as serde::de::SeqAccess>::next_element_seed
   8: <serde::de::impls::<impl serde::de::Deserialize for alloc::vec::Vec<T>>::deserialize::VecVisitor<T> as serde::de::Visitor>::visit_seq
   9: <&mut serde_yaml::de::Deserializer as serde::de::Deserializer>::deserialize_seq
  10: serde_yaml::de::Deserializer::visit_mapping
  11: <&mut serde_yaml::de::Deserializer as serde::de::Deserializer>::deserialize_struct
  12: serde_yaml::de::from_str
  13: espanso::config::Configs::load_config
  14: espanso::config::ConfigSet::load::{{closure}}
  15: espanso::config::ConfigSet::load_default
  16: espanso::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I have not yet uninstalled and reinstalled, but I'm wondering if that's not the only solution. Any help you can provide me would be great. I did not register with root as in another case that I saw.

Activity

  1. KyleSnodgrass commented on Sep 23, 2021

    @KyleSnodgrass
    Author

    Re-installing didn't appear to help with the issue. There must be something else that is causing RUST to panic.

    F0H5 ~ % brew uninstall espanso
    Uninstalling /usr/local/Cellar/espanso/0.7.3... (4 files, 15.3MB)
    F0H5 ~ % espanso start
    zsh: command not found: espanso
    F0H5 ~ %
    F0H5 ~ %
    F0H5 ~ %
    F0H5 ~ % espanso start
    zsh: command not found: espanso
    F0H5 ~ % brew install espanso
    ==> Downloading https://github.com/federico-terzi/modulo/releases/download/v0.1.1/modulo-mac
    Already downloaded: /Users/myusername/Library/Caches/Homebrew/downloads/a53326b42d5444a525d066b481dc684d202164c42fe1050b39c3d1f25b385c98--modulo-mac
    ==> Downloading https://github.com/federico-terzi/espanso/releases/download/v0.7.3/espanso-mac.tar.gz
    Already downloaded: /Users/myusername/Library/Caches/Homebrew/downloads/fca3fe0ca65657b6d7be5f798adbdb83dcffe0fc01cb15997b99ebe7c4415a2f--espanso-mac.tar.gz
    ==> Installing espanso from federico-terzi/espanso
    🍺  /usr/local/Cellar/espanso/0.7.3: 4 files, 15.3MB, built in 14 seconds
    F0H5 ~ % espanso start
    thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/markdown-0.3.0/src/parser/block/unordered_list.rs:84:44
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    F0H5 ~ %
    
  2. KyleSnodgrass commented on Sep 23, 2021

    @KyleSnodgrass
    Author

    I got it working. I did the following:
    -Removed all .yml files in the library except the default.
    -Restarted espanso -> it worked :)
    -Re-added files and restarted espanso until I found the yml that was breaking it.
    -This makes a good case for separating out each of your triggers into individual files.
    -Once the file was located I changed the "markdown:" to "replace:" restarted espanso and it worked.
    -There must be an issue with Markdown and triggers so be careful using them.

  3. federico-terzi commented on Sep 27, 2021

    @federico-terzi
    Collaborator

    Hey @KyleSnodgrass,

    Thanks for reporting this issue! This seems like a bug, would you mind sharing the markdown content that triggered this exception? Any markdown that triggers that panic would be incredibly useful!

    Cheers :)

  4. added
    bug
    on Sep 27, 2021
  5. KyleSnodgrass commented on Sep 28, 2021

    @KyleSnodgrass
    Author

    I think I can do that. I removed a little bit of the text, but validated that it still causes the panic. I guess I should also note that this is within 2 levels of sub folders under user.

    name: ini11
    parent: default
    
    matches:
      #
      - trigger: "ini11 "
        force_clipboard: true
        markdown: |
            Hi ,
    
            My name is {{myname}} from the ...
    
            Problem Description:  
            - 
    
            Action Plan:
            {{gci}}
    
            I will contact you after reviewing the shared information.
            In the meantime, if you need assistance, please feel free to contact me.
    
            You've chosen e-mail as your preferred mode of contact, however, let me know if you would like me to call you as well.
        vars:
          - name: gci
            type: match
            params:
              trigger: "gci1 "
    

    Additionally, I commended out the nested functionality and the panic still existed.

    I have noted unexpected behavior from markdown in general within the confines espanso. I really do like having markdown as an option because it makes pre-made emails and the like so much more pleasant looking.

  6. federico-terzi commented on Sep 30, 2021

    @federico-terzi
    Collaborator

    @KyleSnodgrass Thank you! I was able to reproduce the problem

    It seems to be related to the "empty unordered list" you implicitly created when adding the - char without anything afterwards.

    For example, the following match panics:

      - trigger: "ini11 "
        force_clipboard: true
        markdown: |
            Problem Description:  
            - 
          

    but this one doesn't

      - trigger: "ini11 "
        force_clipboard: true
        markdown: |
            Problem Description:  
            - hello
    

    This error happens because the markdown package we are using is panicking under the hoods.

    The good news is that this is not espanso's fault, the bad one is that we should fix the problem in the markdown package, but it doesn't seem to be maintained currently...

    So we either fork the package and fix the bug, or we replace the package with another one. Either way, this is likely to take a while to be fixed :)

  7. changed the title [-]Espanso won't start: "thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/markdown-0.3.0/src/parser/block/unordered_list.rs:84:44"[/-] [+]Malformed markdown causes espanso to panic[/+] on Sep 30, 2021
  8. KyleSnodgrass commented on Oct 4, 2021

    @KyleSnodgrass
    Author

    Not a problem. I know there's only so much time in the day and that not all people use the markdown feature. However, I've been incorporating it more and more for my communications and it really elevates what you're able to automate. I prefer the markdown to the HTML, it's easier to write for a non-developer.

    The markdown package that is included does tend to have a couple of issue. It changes the size of the text, and you can't adjust it within the markdown, so that's a touch annoying, but it's not the end of the world. I noted that you can change this stuff in HTML with a custom CSS file, but that doesn't seem to integrate well either. So some form of font/size control would be lovely.

    Thanks for all you're doing. I love this application.

  9. federico-terzi commented on Oct 5, 2021

    @federico-terzi
    Collaborator

    Thank you for the feedback! We'll investigate :)

  10. added a commit that references this issue on Oct 21, 2021
    cd89915
  11. added
    RFNR
    on Oct 21, 2021
  12. federico-terzi commented on Oct 26, 2021

    @federico-terzi
    Collaborator
  13. added 2 commits that reference this issue on Feb 11, 2026
    8de5d0d
    921470e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFNRbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions