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

Added with_base64_encoded for complex strings like json to prevent parsing errors. #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ThePinzon
Copy link

Added with_base64_encoded for complex strings like json to prevent parsing errors.

@dmvict
Copy link
Collaborator

dmvict commented Sep 30, 2022

Hello, @ThePinzon

I see no reason to use such a conversion. Input of the function actionOptionsParse is multiline string. It is an array of strings where each line should have the format key : value.
Please, give me an example where the value is complex JSON, and the action will be broken.

@ThePinzon
Copy link
Author

Hi @dmvict,

Thanks for responding.

    - uses: q4mobile/[email protected]
      name: publish
      if: ${{ inputs.build_format == 'aab' && inputs.publish == 'true'}}
      with:
        action: r0adkll/[email protected]
        with: |
          packageName: ${{ steps.environment.outputs.packageName }}
          releaseFiles: ${{steps.sign.outputs.signedReleaseFile}}
          track: ${{ inputs.publish_track }}
          status: ${{ inputs.publish_status }}
          inAppUpdatePriority: ${{ inputs.publish_in_app_update_priority }}
        with_base4_encoded: |
          serviceAccountJsonPlainText: ${{ secrets.publish_android_service_account_json_text_base64_encoded }}
        attempt_limit: 3
        attempt_delay: 30000

Value of secrets.publish_android_service_account_json_text_base64_encoded. I tried removing new lines and spaces from the json fields and tried several iterations of enclosing the value in single quotes, double quotes and escaping the json quote, ticks.

{
  "type": "service_account",
  "project_id": "1111111111111111111111",
  "private_key_id": "1111111111111111111111111",
  "private_key": "-----BEGIN PRIVATE KEY-----\n111111111111111111111\n-----END PRIVATE KEY-----\n",
  "client_email": "gcp-deployment-service-account@1111111111111111-1111111.iam.gserviceaccount.com",
  "client_id": "11111111111111111111111111",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/gcp-deployment-service-account%40pc-api-1111111111111111-11111111111.iam.gserviceaccount.com"
}

@mikeage
Copy link

mikeage commented May 20, 2024

FWIW, I had this problem with a secret that had embedded newlines:

with: |
  foo: ${{ secret.HAS_EMBEDDED_NEWLINES }}
  bar: something
  baz: blahblah

Gave this error:

Error: can not read a block mapping entry; a multiline key may not be an implicit key (53:20)
50 | 0WNh6LX/nH7f2STR09fjDLsfcHUKRfSRUk/c/o+Yzefqxx8wt/ ...
51 | qAzC47DFXfoXkTVuIDdLF7buCBO9NYUWMr90dOMCaS+4Ed7yFf ...
52 | ***
53 | bar: something
----------^
54 | baz: blahblah

Where the lines beginning 0WN and qAz are (slightly obfuscated versions of) the secret that it didn't correctly mask because they were cropped.

But in my case, the foo parameter was already base64, and so I could remove the new lines with no issue.

(this is not directly relevant to the issue, but I found this one while searching for my error, which also happened due to embedded newlines)

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 this pull request may close these issues.

3 participants