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

Quotes Not Supported For Secrets or Build-Args #245

Closed
malkam03 opened this issue Dec 3, 2020 · 8 comments
Closed

Quotes Not Supported For Secrets or Build-Args #245

malkam03 opened this issue Dec 3, 2020 · 8 comments

Comments

@malkam03
Copy link
Contributor

malkam03 commented Dec 3, 2020

Behavior

When you provide a secret value with quotes, like a JSON. The action fails with:

> Run docker/build-push-action@v2
📣 Buildx version: 0.4.2
Error: Invalid Opening Quote: a quote is found inside a field at line 1

Escaping the quotes or using single quotes doesn't help either, tried:

{"host":"host","user":"user","pass":"pass"}
'{"host":"host","user":"user","pass":"pass"}'
{'host':'host','user':'user','pass':'pass'}
"{'host':'host','user':'user','pass':'pass'}"
{\"host\":\"host\",\"user\":\"user\",\"pass\":\"pass\"}
'{\"host\":\"host\",\"user\":\"user\",\"pass\":\"pass\"}'

Steps to reproduce this issue

  1. Set a secret with quotes. E.g: SERVER with value {"host":"host","user":"user","pass":"pass"}
  2. Use that secret for either the secret or build-args:
-
  	name: Build and Push image
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          tags: ${{ env.IMAGE_NAME }}:latest
          file: ./Dockerfile
          build-args: |
            SERVER=${{ secrets.SERVER }}
          secrets: |
            SERVER=${{ secrets.SERVER }}
  1. Run the workflow

Expected behaviour

Expected to set the secret value to either the build-args or secrets so it can be used at build.

Actual behaviour

The parsing of the values return Error: Invalid Opening Quote: a quote is found inside a field at line 1

Configuration

  • Repository URL (if public): Not public, but you can use the info provided above to reproduce the error.
  • Build URL (if public): Not public, but you can use the info provided above to reproduce the error.

Logs

Download the log file of your build and attach it to this issue.

Can't do this, the logs are not public.

@crazy-max
Copy link
Member

@malkam03 As explained in the README, quote signs need to be doubled for escaping.

@malkam03
Copy link
Contributor Author

malkam03 commented Dec 3, 2020

@malkam03 As explained in the README, quote signs need to be doubled for escaping.

Ah, sorry beginners error. Thank you for your prompt response!

@malkam03 malkam03 closed this as completed Dec 3, 2020
@malkam03 malkam03 reopened this Dec 3, 2020
@malkam03
Copy link
Contributor Author

malkam03 commented Dec 3, 2020

@crazy-max double escaping the quotes is not working either. Maybe I'm doing something wrong? I think that this can be added more specifically to the documentation. If I can make it work and you accept MR's I can create one. I tried both using it with the secret or testing an explicit string:

SERVER=${{ secrets.SERVER }} # setting the value of SERVER secret to {\\"some\\":\\"value\\",\\"goes\\":\\"here\\"}
SERVER={\\"some\\":\\"value\\",\\"goes\\":\\"here\\"}

@crazy-max
Copy link
Member

@malkam03 As I said, quote signs need to be doubled for escaping. So in your case:

SERVER={""some"":""value"",""goes"":""here""}

@malkam03
Copy link
Contributor Author

malkam03 commented Dec 3, 2020

Ah, is double quote not double escaped. Got it, thank you!

@malkam03 malkam03 closed this as completed Dec 3, 2020
@malkam03
Copy link
Contributor Author

malkam03 commented Dec 3, 2020

Sorry, that's not working either @crazy-max, same error and same tests:

SERVER=${{ secrets.SERVER }} # setting the value of SERVER secret to {""some"":""value"",""goes"":""here""}
SERVER={""some"":""value"",""goes"":""here""}

@malkam03 malkam03 reopened this Dec 3, 2020
@crazy-max
Copy link
Member

@malkam03 Try with "SERVER=${{ secrets.SERVER }}"

@malkam03
Copy link
Contributor Author

malkam03 commented Dec 3, 2020

Yes, that works! Thank you very much! I created a PR if it works for someone else #246.

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

No branches or pull requests

2 participants