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

Getting "Error: Expects non-primitive" when using multiple multiline fields #122

Closed
darkxeno opened this issue Nov 13, 2023 · 13 comments
Closed

Comments

@darkxeno
Copy link

darkxeno commented Nov 13, 2023

Example inputs used, gathered from github action logs:

Wandalen/[email protected]
  with:
    action: docker/build-push-action@v3
    attempt_limit: 2
    attempt_delay: 2000
    with: file: ./Dockerfile
  tags: ***.dkr.ecr.us-east-1.amazonaws.com/IMAGE_NAME:8771665,***.dkr.ecr.us-east-1.amazonaws.com/IMAGE_NAME:latest
  context: ./.
  load: true
  push: false
  cache-from: type=registry,ref=***.dkr.ecr.us-east-1.amazonaws.com/IMAGE_NAME:latest
  cache-to: type=inline
  ssh: |
    
  build-args: |
    ***
  
  
  env:
    AWS_DEFAULT_REGION: us-east-1
    AWS_REGION: us-east-1
    AWS_ACCESS_KEY_ID: ***
    AWS_SECRET_ACCESS_KEY: ***
    AWS_SESSION_TOKEN: ***

Error:
Error: Expects non-primitive

The same error happens on the post run step.

Post job cleanup.
Post job cleanup.
Post job cleanup.
Error: Expects non-primitive
Post job cleanup.
Logging out of registry ***.dkr.ecr.us-east-1.amazonaws.com
Post job cleanup.
Post job cleanup.
Removing builder
Cleaning up certificates

Using the same action docker/build-push-action@v3 without "Wandalen/[email protected]" works as expected.

Any idea about what could be wrong? somehow seem to only be happening with multiline fields.

@darkxeno darkxeno changed the title Getting "Error: Expects non-primitive" when using build-args and ssh fields as multiline fields Getting "Error: Expects non-primitive" when using multiple multiline fields Nov 13, 2023
@dmvict
Copy link
Collaborator

dmvict commented Nov 14, 2023

Hello @darkxeno

The action is sensible to indentations in with input. I believe that the problem is in indentations. Please, replace first part with:

- uses: Wandalen/[email protected]
  with:
    action: docker/build-push-action@v3
    attempt_limit: 2
    attempt_delay: 2000
    with: |
      file: ./Dockerfile
      tags: ***.dkr.ecr.us-east-1.amazonaws.com/IMAGE_NAME:8771665,***.dkr.ecr.us-east-1.amazonaws.com/IMAGE_NAME:latest
      context: ./.
      load: true
      push: false
      cache-from: type=registry,ref=***.dkr.ecr.us-east-1.amazonaws.com/IMAGE_NAME:latest
      cache-to: type=inline
      ssh: |
    
      build-args: |
        ***

Take care about indentations in field ssh and build-args. Use example from the documentation, please.

Also, I fixed line with: file: ./Dockerfile. Now the line looks like

      with: | 
        file: ./Dockerfile`

@darkxeno
Copy link
Author

Thanks for the fast response @dmvict

What i pasted above was obtained from the github action logs.

This is what i was using on the pipelines yaml, i think this is correctly indented.

    - name: Build image ${{ inputs.image_name }}
      uses: Wandalen/[email protected]
      with:
        action: docker/build-push-action@v3
        attempt_limit: 2
        attempt_delay: 2000
        with: |
          file: ${{ inputs.repo_path }}/${{ inputs.dockerfile }}
          tags: ${{ steps.set-variables.outputs.IMAGE_URL_WITH_TAG }},${{ steps.set-variables.outputs.IMAGE_URL_WITH_LATEST }}
          context: ${{ inputs.repo_path }}/${{ inputs.context }}
          load: ${{ inputs.push != 'true' }}
          push: ${{ inputs.push }}
          cache-from: type=registry,ref=${{ steps.set-variables.outputs.IMAGE_URL_WITH_LATEST }}
          cache-to: type=inline
          ssh: |
            ${{ inputs.ssh_private_key != '' && format('default={0}', env.SSH_AUTH_SOCK) || '' }}
          build-args: |
            ${{ inputs.build_args }}

Thanks for the support.

@dmvict
Copy link
Collaborator

dmvict commented Nov 16, 2023

Hello @darkxeno

Yes, the inputs seems to be correct. Please, check that all inputs are singleline or update indentations for multiline inputs. For example, if your build-args input is

--arg1 arg
-- arg2 arg

Then the input will be formatted as

build-args: | 
  --arg1 arg
--arg2 arg

but the actions expects that the second line has same indentation as the first one (or bigger).

@darkxeno
Copy link
Author

darkxeno commented Nov 16, 2023

i think i get your point, as we are using | as part of a string, its probably not indenting multiline strings automatically?

the values of build-args is original constructed like this on the input of the custom action:

build_args: |
  ENV_VAR1=value1
  ENV_VAR2=value2

and after that provided as the variable ${{ inputs.build_args }} to this action

So you mean if i some force the correct indentation to all lines should be working properly?

Thanks again @dmvict

@dmvict
Copy link
Collaborator

dmvict commented Nov 17, 2023

Hello @darkxeno

I think it should work. The best way is to create experimental workflow with public data and hardcoded values.

@mycarrysun
Copy link

I'm getting the same issue - here is what I'm using in the workflow:

    - name: Build image
      uses: Wandalen/[email protected]
      with:
        action: docker/build-push-action@v3
        with: |
          context: .
          target: ${{ inputs.build-target }}
          file: ${{ inputs.dockerfile }}

And here's what shows in the github actions log output as what is being passed to the Wandalen/wretry.action action:

Run Wandalen/[email protected]_js_action
  with:
    action: docker/build-push-action@v3
    with: context: .
    target: release
    file: docker/Dockerfile.backend

So somehow there is a problem with indentation. I have also tried an extra set of indentation after the first line in the with multiline string but got the same result:

    - name: Build image
      uses: Wandalen/[email protected]
      with:
        action: docker/build-push-action@v3
        with: |
          context: .
            target: ${{ inputs.build-target }}
            file: ${{ inputs.dockerfile }}

I think there is a bug in the action code somewhere.

@dmvict
Copy link
Collaborator

dmvict commented Jan 29, 2024

Hello @mycarrysun

I hope I'll find a time to check and fix the issue.

@dylanmtaylor
Copy link

dylanmtaylor commented Feb 18, 2024

Hello @dmvict. I am trying to use this action and am getting the same error. I tried to make a PR to add this action to universal blue's build process at ublue-os/main#503 and I am seeing this "Error: Expects non-primitive" issue.

@dylanmtaylor
Copy link

This seems related to the amount of left indenting on a multi-line string.

@dmvict
Copy link
Collaborator

dmvict commented Feb 19, 2024

Hello @dylanmtaylor

Yes, the indentations are important.
I'm improving the logic for commands and I hope it will be published soon.

@dmvict
Copy link
Collaborator

dmvict commented Mar 6, 2024

Hello @dylanmtaylor @mycarrysun @darkxeno

Can you try new version of the action? I improved a parser a time ago.

@mycarrysun
Copy link

I have a different error now, seems like it won't work for private repo github actions.

Screen Shot 2024-03-06 at 11 11 43 AM

@dmvict
Copy link
Collaborator

dmvict commented Mar 7, 2024

Hello @mycarrysun

Thank you for report. Please, open new issue for the error. I'll try to find a time to solve it.

@dmvict dmvict closed this as completed Mar 7, 2024
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

4 participants