Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tera templates in depends cannot be rendered #3668

Closed
risu729 opened this issue Dec 18, 2024 · 2 comments · Fixed by #3708
Closed

tera templates in depends cannot be rendered #3668

risu729 opened this issue Dec 18, 2024 · 2 comments · Fixed by #3708
Labels

Comments

@risu729
Copy link
Contributor

risu729 commented Dec 18, 2024

Describe the bug
tera templates in depends, depends_post, or wait_for are split by whitespace before rendering.

To Reproduce
mise.toml

[tasks.test]
depends = ["{% if env.CI is defined %}check{% else %}lint{% endif %}"]
run = "echo hello"

mise test

$ mise test
mise WARN  rendering task: 
   0: Failed to parse '__tera_one_off'
   1:  --> 1:1
        |
      1 | {%
        | ^---
        |
        = expected a template

Location:
   src/task/mod.rs:426

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
mise ERROR error parsing glob '{%': unclosed alternate group; missing '}' (maybe escape '{' with '[{]'?)
mise ERROR Run with --verbose or MISE_VERBOSE=1 for more information

Expected behavior
lint is executed.

Additional context
from_str splits depends before rendering. It should be split after rendering but requires code structure changes.

fn from_str(s: &str) -> Result<Self, Self::Err> {
let parts = s.split_whitespace().collect_vec();
if parts.is_empty() {
return Err("Task name is required".to_string());
}
Ok(Self {
task: parts[0].to_string(),
args: parts[1..].iter().map(|s| s.to_string()).collect(),
})
}

mise doctor output

version: 2024.12.13 linux-x64 (c970664 2024-12-17)
activated: yes
shims_on_path: no

build_info:
  Target: x86_64-unknown-linux-gnu
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Tue, 17 Dec 2024 22:05:20 +0000
  Rust Version: rustc 1.83.0 (90b35a623 2024-11-26)
  Profile: release

shell:
  /bin/bash
  GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu)
  Copyright (C) 2022 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

  This is free software; you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.

dirs:
  cache: ~/.cache/mise
  config: ~/.config/mise
  data: ~/.local/share/mise
  shims: ~/.local/share/mise/shims
  state: ~/.local/state/mise

config_files:
  ~/.config/mise/config.toml
  ~/ghq/github.com/risu729/dotfiles/mise.toml

backends:
  aqua
  asdf
  cargo
  core
  gem
  go
  npm
  pipx
  spm
  ubi
  vfox

plugins:
  gradle  https://github.com/rfrancis/asdf-gradle.git#3af5633
  pdm     https://github.com/1oglop1/asdf-pdm.git#0223762
  yarn    https://github.com/mise-plugins/asdf-yarn.git#74ea3b9

toolset:
  aqua:BurntSushi/ripgrep@14.1.1
  aqua:astral-sh/uv@0.5.10
  aqua:biomejs/biome@1.9.4
  aqua:cargo-bins/cargo-binstall@1.10.11
  aqua:cli/cli@2.63.2
  aqua:crate-ci/typos@1.28.4
  aqua:ducaale/xh@0.23.0
  aqua:google/yamlfmt@0.14.0
  aqua:jqlang/jq@1.7.1
  aqua:junegunn/fzf@0.56.3
  aqua:kellyjonbrazil/jc@1.25.4
  aqua:koalaman/shellcheck@0.10.0
  aqua:mvdan/sh@3.10.0
  aqua:pnpm/pnpm@9.15.0
  aqua:sharkdp/fd@10.2.0
  aqua:sigstore/cosign@2.4.1
  aqua:suzuki-shunsuke/ghalint@1.1.0
  aqua:suzuki-shunsuke/pinact@1.0.0
  aqua:x-motemen/ghq@1.7.1
  asdf:gradle@8.11.1
  asdf:yarn@4.5.3
  cargo:eza@0.20.10
  cargo:lychee@0.17.0
  core:bun@1.1.39
  core:go@1.23.4
  core:java@23.0.1
  core:node@23.4.0
  core:python@3.13.1
  core:rust@1.83.0
  npm:cspell@8.17.1
  npm:ignore-sync@7.0.1
  npm:markdownlint-cli2@0.16.0
  npm:prettier@3.4.2
  npm:renovate@39.72.2
  pipx:yamllint@1.35.1
  ubi:dandavison/delta@0.18.2
  ubi:jdx/usage@1.6.0
  ubi:rhysd/actionlint@1.7.4
  ubi:sharkdp/bat@0.24.0
  ubi:slsa-framework/slsa-verifier@2.6.0
  ubi:tamasfe/taplo[matching=full]@0.9.3

path:
  ~/.local/share/mise/installs/bun/1.1.39/bin
  ~/.local/share/mise/installs/node/23.4.0/bin
  ~/.local/share/mise/installs/cargo-binstall/1.10.11
  ~/.local/share/mise/installs/uv/0.5.10/uv-x86_64-unknown-linux-musl
  ~/.local/share/mise/installs/aqua-biomejs-biome/1.9.4
  ~/.local/share/mise/installs/actionlint/1.7.4/bin
  ~/.local/share/mise/installs/aqua-suzuki-shunsuke-ghalint/1.1.0
  ~/.local/share/mise/installs/aqua-suzuki-shunsuke-pinact/1.0.0
  ~/.local/share/mise/installs/taplo/0.9.3/bin
  ~/.local/share/mise/installs/npm-prettier/3.4.2/bin
  ~/.local/share/mise/installs/markdownlint-cli2/0.16.0/bin
  ~/.local/share/mise/installs/shfmt/3.10.0
  ~/.local/share/mise/installs/shellcheck/0.10.0/shellcheck-v0.10.0
  ~/.local/share/mise/installs/yamlfmt/0.14.0
  ~/.local/share/mise/installs/yamllint/1.35.1/bin
  ~/.local/share/mise/installs/npm-renovate/39.72.2/bin
  ~/.local/share/mise/installs/npm-cspell/8.17.1/bin
  ~/.local/share/mise/installs/cargo-lychee/0.17.0/bin
  ~/.local/share/mise/installs/typos/1.28.4
  ~/.local/share/mise/installs/npm-ignore-sync/7.0.1/bin
  ~/.local/share/mise/installs/yarn/4.5.3/bin
  ~/.local/share/mise/installs/pnpm/9.15.0
  ~/.local/share/mise/installs/java/23.0.1/bin
  ~/.local/share/mise/installs/gradle/8.11.1/bin
  ~/.cargo/bin
  ~/.local/share/mise/installs/python/3.13.1/bin
  ~/.local/share/mise/installs/go/1.23.4/bin
  ~/.local/share/mise/installs/usage/1.6.0/bin
  ~/.local/share/mise/installs/cosign/2.4.1
  ~/.local/share/mise/installs/slsa-verifier/2.6.0/bin
  ~/.local/share/mise/installs/jq/1.7.1
  ~/.local/share/mise/installs/github-cli/2.63.2/gh_2.63.2_linux_amd64/bin
  ~/.local/share/mise/installs/ghq/1.7.1/ghq_linux_amd64
  ~/.local/share/mise/installs/aqua-kellyjonbrazil-jc/1.25.4
  ~/.local/share/mise/installs/delta/0.18.2/bin
  ~/.local/share/mise/installs/ripgrep/14.1.1/ripgrep-14.1.1-x86_64-unknown-linux-musl
  ~/.local/share/mise/installs/cargo-eza/0.20.10/bin
  ~/.local/share/mise/installs/bat/0.24.0/bin
  ~/.local/share/mise/installs/fd/10.2.0/fd-v10.2.0-x86_64-unknown-linux-musl
  ~/.local/share/mise/installs/fzf/0.56.3
  ~/.local/share/mise/installs/xh/0.23.0/xh-v0.23.0-x86_64-unknown-linux-musl
  ~/.vscode-server-insiders/bin/95386dec787946547812c7ee9d38cba19d6a6398/bin/remote-cli
  ~/.local/bin
  /usr/local/sbin
  /usr/local/bin
  /usr/sbin
  /usr/bin
  /sbin
  /bin
  /usr/games
  /usr/local/games
  /usr/lib/wsl/lib
  /mnt/c/Windows/system32
  /mnt/c/Windows
  /mnt/c/Windows/System32/Wbem
  /mnt/c/Windows/System32/WindowsPowerShell/v1.0/
  /mnt/c/Windows/System32/OpenSSH/
  /mnt/c/Program Files/dotnet/
  /mnt/c/Program Files/Tailscale/
  /mnt/c/Program Files/Cloudflare/Cloudflare WARP/
  /mnt/c/Program Files/PowerShell/7-preview/preview
  /mnt/c/Users/risu/AppData/Local/Microsoft/WindowsApps
  /mnt/c/Users/risu/AppData/Local/JetBrains/Toolbox/scripts
  /mnt/c/Users/risu/AppData/Local/Programs/Microsoft VS Code Insiders/bin
  /snap/bin
  ~/.vscode-server-insiders/data/User/globalStorage/github.copilot-chat/debugCommand

env_vars:
  MISE_SHELL=bash

settings:
  experimental    true  ~/.config/mise/config.toml
  npm.bun         true  ~/.config/mise/config.toml
  pin             true  ~/.config/mise/config.toml
  pipx.uvx        true  ~/.config/mise/config.toml
  python.compile  false ~/.config/mise/config.toml
  experimental    true  ~/ghq/github.com/risu729/dotfiles/mise.toml
  npm.bun         true  ~/ghq/github.com/risu729/dotfiles/mise.toml
  pipx.uvx        true  ~/ghq/github.com/risu729/dotfiles/mise.toml

No problems found
@risu729 risu729 added the bug label Dec 18, 2024
@jdx
Copy link
Owner

jdx commented Dec 18, 2024

yeah this will be a pain. We'll probably have to change the model type to Vec<Vec<String>> (I think) and parse it wherever we use it

@risu729
Copy link
Contributor Author

risu729 commented Dec 20, 2024

Thanks for fixing it! Confirmed it now works almost fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants