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

nextflow secrets does not work with secrets that contain $ #4977

Closed
jdidion opened this issue May 7, 2024 · 3 comments · Fixed by #5021
Closed

nextflow secrets does not work with secrets that contain $ #4977

jdidion opened this issue May 7, 2024 · 3 comments · Fixed by #5021

Comments

@jdidion
Copy link

jdidion commented May 7, 2024

Bug report

A secret that contains a $ character results in an error when running a task configured to use the secret. The problem looks to be that that when the .nf-XXX.secrets file is generated, it contains export commands with double-quoted rather than single-quoted values.

Expected behavior and actual behavior

I expect that there will be no restrictions on the characters that I can store in secrets.

Steps to reproduce the problem

main.nf:

process secret_test {
  secret 'FOO'
  script:
    """
    echo '\$FOO'
    """
}

workflow {
  secret_test()
}
nextflow secrets set FOO '$bar'
nextflow run main.nf`

Program output

/dev/stdin: line 2: bar: unbound variable

The ~/.nextflow/secrets/.nf-XXX.secrets file contains:

export FOO="$bar"

Environment

  • Nextflow version: 23.10.1
  • Java version: 11.0.21
  • Operating system: macOS
  • Bash version: zsh 5.9
@pditommaso
Copy link
Member

Tricky, @marcodelapierre you may want to give it a try

@marcodelapierre
Copy link
Member

Given a first look.

@pditommaso, was there a specific rationale for using double quotes in the export definitions of secrets?

At this stage, I am considering whether one of these might be a viable solution (still under investigation):

  1. use single quotes instead of double quotes in the secrets file definition
  2. allow flexibility via specific nextflow secrets set option, e.g. --single-quote or similar
  3. allow flexibility by mirroring Bash export behaviour, and hence adapt definition based on the string input by the user (does the user string contain single vs double quotes?)

@pditommaso
Copy link
Member

Maybe this is the best solition

script << /export $name="${Escape.variable(value)}"/

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 a pull request may close this issue.

3 participants