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

Crowdin Action does not create PR and fails with error: jq: error (at <stdin>:4): Cannot index string with string "head" #67

Closed
sumitahluwalia opened this issue Apr 23, 2021 · 15 comments
Assignees
Labels
bug Something isn't working

Comments

@sumitahluwalia
Copy link

sumitahluwalia commented Apr 23, 2021

Describe the bug
Pull request does not get created when the crowdin executed is executed.
The script fails with error:

 jq: error (at <stdin>:4): Cannot index string with string "head"

To Reproduce

  1. I previously had github integration enabled for the same project. I just tried to switch to using the action.
  2. I have the action added here: https://github.com/sumitahluwalia/crowdin/blob/main/.github/workflows/main.yml
  3. You can see my action executed here: https://github.com/sumitahluwalia/crowdin/runs/2417311249
  4. crowdin.yml file: https://github.com/sumitahluwalia/crowdin/blob/main/crowdin.yml

Expected behavior
The PR request should be created.

Additional context

STARTING CROWDIN ACTION
UPLOAD SOURCES
✔️  Fetching project info
✔️  File 'FileToTranslate.json'
UPLOAD TRANSLATIONS
✔️  Fetching project info
✔️  Translation file 'Translations/fr.json' has been uploaded
✔️  Translation file 'Translations/en.json' has been uploaded
DOWNLOAD TRANSLATIONS
✔️  Fetching project info
✔️  Building ZIP archive with the latest translations
✔️  Building translation (100%)
✔️  Downloading translation
✔️  Extracted: 'Translations/en.json'
✔️  Extracted: 'Translations/fr.json'
CONFIGURATION GIT USER
Already on 'main'
M	Translations/en.json
M	Translations/fr.json
Your branch is up to date with 'origin/main'.
Switched to a new branch 'l10n_crowdin_action'
PUSH TO BRANCH l10n_crowdin_action
[l10n_crowdin_action d62d3e9] New Crowdin translations by Github Action
 2 files changed, 12 insertions(+), 20 deletions(-)
To https://github.com/sumitahluwalia/crowdin.git
 + 6355e60...d62d3e9 l10n_crowdin_action -> l10n_crowdin_action (forced update)
CHECK IF ISSET SAME PULL REQUEST
jq: error (at <stdin>:4): Cannot index string with string "head"
@sumitahluwalia sumitahluwalia added the bug Something isn't working label Apr 23, 2021
@sumitahluwalia sumitahluwalia changed the title Crowdin Action fails with error: jq: error (at <stdin>:4): Cannot index string with string "head" Crowdin Action does not create PR and fails with error: jq: error (at <stdin>:4): Cannot index string with string "head" Apr 23, 2021
@og-fox
Copy link

og-fox commented Apr 23, 2021

Hi @sumitahluwalia! I'm sorry to hear you were faced with such behavior and thank you a million for bringing this to our attention! Already asking the tech team to take a look

@sumitahluwalia
Copy link
Author

Hi @sumitahluwalia! I'm sorry to hear you were faced with such behavior and thank you a million for bringing this to our attention! Already asking the tech team to take a look

Thanks a lot for the quick response! Please let me know incase I can use any work around as well for this.

@VBeytok VBeytok self-assigned this May 12, 2021
@VBeytok
Copy link
Collaborator

VBeytok commented Sep 17, 2021

@sumitahluwalia Hi sorry for so fast response 😅 , is the problem exists?

@subbuswaroop
Copy link

subbuswaroop commented Oct 6, 2021

@VBeytok I started facing the same issue from today.

  1. My action file: https://github.com/subbuswaroop/crowdin-sync-repo/blob/main/.github/workflows/main.yml
  2. Action execution : https://github.com/subbuswaroop/crowdin-sync-repo/actions/runs/1312868143
  3. Crowdin.yml file : https://github.com/subbuswaroop/crowdin-sync-repo/blob/main/crowdin.yml

Expected Behaviour:
Pull request should be created

Logs
`
STARTING CROWDIN ACTION
UPLOAD SOURCES
✔️ Fetching project info
✔️ File 'en.json'

┌────────────────────────────────────────────────────────────┐
│ New version of Crowdin CLI is available! 3.1.13 -> 3.7.0 │
│ Please update for best experience! │
└────────────────────────────────────────────────────────────┘
DOWNLOAD TRANSLATIONS
✔️ Fetching project info
✔️ Building ZIP archive with the latest translations
✔️ Building translation (100%)
✔️ Downloading translation
✔️ Extracted: 'locales-json/hi-IN.json'
✔️ Extracted: 'locales-json/ta-IN.json'
✔️ Extracted: 'locales-json/zh-TW.json'

┌────────────────────────────────────────────────────────────┐
│ New version of Crowdin CLI is available! 3.1.13 -> 3.7.0 │
│ Please update for best experience! │
└────────────────────────────────────────────────────────────┘
CONFIGURATION GIT USER
Switched to a new branch 'translations_branch'
PUSH TO BRANCH translations_branch
[translations_branch 1dd140b] New Crowdin translations by Github Action
3 files changed, 24 insertions(+)
create mode 100644 locales-json/hi-IN.json
create mode 100644 locales-json/ta-IN.json
create mode 100644 locales-json/zh-TW.json
remote:
remote: Create a pull request for 'translations_branch' on GitHub by visiting:
remote: https://github.com/subbuswaroop/crowdin-sync-repo/pull/new/translations_branch
remote:
To https://github.com/subbuswaroop/crowdin-sync-repo.git

  • [new branch] translations_branch -> translations_branch
    CHECK IF ISSET SAME PULL REQUEST
    jq: error (at :4): Cannot index string with string "head"
    `

Any help would be appreciated :)

@VBeytok
Copy link
Collaborator

VBeytok commented Oct 7, 2021

Hi @subbuswaroop! Let's try first set new version of github action uses: crowdin/github-action@1.4.0 and re-run action.

@subbuswaroop
Copy link

Hey @VBeytok .. Tried using crowdin/github-action@1.4.0 but still getting the same error

@subbuswaroop
Copy link

@VBeytok Were you able to find anything? 🙂

@VBeytok
Copy link
Collaborator

VBeytok commented Oct 11, 2021

Hi @subbuswaroop
I reproduced your error, its happened because your personal token is wrong or expired witch you use in ${{ secrets.PRIVATE_TOKEN }} update secret or use the default ${{ secrets.GITHUB_TOKEN }}

@subbuswaroop
Copy link

@VBeytok Thank you for the response. But I'm still getting the same error even after using the default ${{ secrets.GITHUB_TOKEN }}. I can see that a new branch is getting created. But only the PULL_REQUEST fails. Do I need to delete the branch and try running the script again? Will that work?

@VBeytok
Copy link
Collaborator

VBeytok commented Oct 12, 2021

@subbuswaroop try this pull request subbuswaroop/crowdin-sync-repo#5. For this case, you do not need to delete branch.

@subbuswaroop
Copy link

@VBeytok Sorry for the dumb response earlier. I was actually changing the ${{ secrets.GITHUB_TOKEN }} in another workflow file and was expecting the current one to work 😒.

It's working now. Thank you very much. Have a great day :)

@VBeytok
Copy link
Collaborator

VBeytok commented Oct 12, 2021

@subbuswaroop Thanks, you too!

@googol7
Copy link

googol7 commented Aug 7, 2024

I just had the same problem and was able to solve it by using:

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Does the documentation need an update? Here for example you write:

# A classic GitHub Personal Access Token with the 'repo' scope selected (the user should have write access to the repository).
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

In this official video https://youtu.be/5b7BMuCoKGg?t=382 he says:

"You do need to have a secrets.GITHUB_TOKEN. You can create your GitHub by yourself. You can also use an automatic one that GitHub provides."

That doesn't seem to be true.

@andrii-bodnar
Copy link
Member

@googol7 please refer to the Permissions section in the Readme.

In case you want to use an automatic GitHub authentication token, you need to assign the write permission to your job and allow GH Actions to create Pull Requests.

@googol7
Copy link

googol7 commented Aug 8, 2024

Could the error message be improved when there's a problem with the token?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants