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

Extra whitespace detected at the end of targets in list-target job #1661

Closed
cappyzawa opened this issue May 3, 2024 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@cappyzawa
Copy link
Contributor

cappyzawa commented May 3, 2024

tfaction version

v1.3.2

Overview

Occasionally, the list-target job detects targets with extra whitespace at the end. Upon investigating, I discovered that in the follow-up PR body, \n is sometimes treated as \r\n.
The reason for this behavior is unclear.
When the newline character is \r\n, extra whitespace remains even after --> is removed from the end of the first line in the PR body.

How to reproduce

tfaction-root.yaml

plan_workflow_name: test
scaffold_working_directory:
  skip_adding_aqua_packages: true
target_groups:
- working_directory: one
  target: one

tfaction.yaml

{}

GitHub Actions Workflow

name: plan
on:
  pull_request:
    branches: [main]
env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  TFACTION_IS_APPLY: "false"
permissions:
  id-token: write
  contents: read
  pull-requests: write
jobs:
  list-targets:
    runs-on: ubuntu-latest
    outputs:
      targets: ${{ steps.list-targets.outputs.targets }}
    steps:
    - uses: actions/checkout@v4.1.1
    - uses: aquaproj/aqua-installer@v3.0.0
      with:
        aqua_version: v2.25.1

    - uses: suzuki-shunsuke/tfaction/list-targets@v1.3.2
      id: list-targets

Other related code such as local Registry


GitHub Actions' log

Run suzuki-shunsuke/tfaction/list-targets-with-changed-files@v1.3.2
targets: [{"target":"one","runs_on":"ubuntu-latest","job_type":"terraform"},{"target":"one ","runs_on":"ubuntu-latest","job_type":"terraform"}]

PR comment

<!-- tfaction follow up pr target=one -->
@cappyzawa

Expected behaviour

The list-target job should not detect any targets with extra whitespace at the end.

Actual behaviour

Sometimes the list-target job inadvertently detects targets with extra whitespace at their end.

Important Factoids

No response

Note

The job that confirmed that \r\n is included as a newline code is https://github.com/cappyzawa/tfaction-debug/actions/runs/8934424916/job/24541344967.

@cappyzawa cappyzawa added the bug Something isn't working label May 3, 2024
@cappyzawa
Copy link
Contributor Author

I created #1660 as one of the solutions to the problem.

@cappyzawa cappyzawa changed the title Sometimes list-target job detects a target that contains extra trailing spaces. Extra whitespace detected at the end of targets in list-target job May 3, 2024
@suzuki-shunsuke
Copy link
Owner

Thank you for your report!
v1.5.0 is out 🎉
https://github.com/suzuki-shunsuke/tfaction/releases/tag/v1.5.0

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
Archived in project
Development

No branches or pull requests

2 participants