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

Error due to Hypen(-) in key name in yaml #567

Closed
prabhat-kumar-ts opened this issue Feb 10, 2024 · 2 comments
Closed

Error due to Hypen(-) in key name in yaml #567

prabhat-kumar-ts opened this issue Feb 10, 2024 · 2 comments

Comments

@prabhat-kumar-ts
Copy link

prabhat-kumar-ts commented Feb 10, 2024

Not updating yaml file due to hyphen in key name and generating error.

Run fjogeleit/yaml-update-action@main
  with:
    repository: xxx/test-repo
    workDir: release
    valueFile: manifest.yaml
    propertyPath: app.test-repo
    value: v1.3.5
    branch: develop
    targetBranch: develop
    createPR: false
    message: Update Image Version to v1.3.5
    token: ***
    noCompatMode: false
    quotingType: '
    force: false
    masterBranchName: master
    githubAPI: https://api.github.com
    commitChange: true
    updateFile: false
    labels: yaml-updates
    commitUserName: github-actions[bot]
    commitUserEmail: 41898[2](https://github.com/xxxx/test-repo/actions/runs/781150244/job/21433313884#step:5:2)82+github-actions[bot]@users.noreply.github.com

Error: failed to create PR: Error: Lexical error on line 1. Unrecognized text.
$.app.test-repo
----------^
@fjogeleit
Copy link
Owner

Please check e.g #433

@younsl
Copy link

younsl commented May 8, 2024

@prabhat-kumar-ts Hi, fellas.

In my case, I found the perfect solution for handling jsonPath:


Solution

The value structure of the helm chart I was trying to change is as follows:

# example-chart/values.yaml
...
podLabels:
  restarting-trigger-salt: '0434'

I observed that setting propertyPath to '.podLabels.restarting-trigger-salt' or .podLabels[restart-trigger-salt] does not work.

# Error log for Github Actions Workflow
2024-05-08T04:24:10.8095603Z ##[error]Error: Parse error on line 1:
$..podLabels[restarting-trigger-s
-------------^
Expecting 'STAR', 'SCRIPT_EXPRESSION', 'INTEGER', 'ARRAY_SLICE', 'FILTER_EXPRESSION', 'QQ_STRING', 'Q_STRING', got 'IDENTIFIER'

To make it work properly, propertyPath must be wrapped in double quotes, such as '.podLabels["restarting-trigger-salt"]'.

- '.podLabels[restarting-trigger-salt]'
+ '.podLabels["restarting-trigger-salt"]'

In Actions Workflow, the normally executed yaml update step is as follows.

# .github/workflows/yaml-update.yml
      - name: Update helm chart
        uses: actions/yaml-update-action@main
        with:
          valueFile: ${{ inputs.application }}/values.yaml
          propertyPath: '.podLabels["restarting-trigger-salt"]'
          value: ${{ env.RESTART_TRIGGER_SALT }}

Related issue

#567, #433


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

3 participants