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

[BUG]:Cannot read a block mapping entry; a multiline key may not be an implicit key #228

Open
1 task done
BigBang001 opened this issue Nov 12, 2024 · 1 comment · May be fixed by #227
Open
1 task done

[BUG]:Cannot read a block mapping entry; a multiline key may not be an implicit key #228

BigBang001 opened this issue Nov 12, 2024 · 1 comment · May be fixed by #227
Assignees
Labels
bug Something isn't working gssoc-ext GSSoC'24 Extended Version hacktoberfest Hacktober Collaboration hacktoberfest-accepted Hacktoberfest 2024 level1 10 Points 🥇

Comments

@BigBang001
Copy link
Contributor

Has this bug been raised before?

  • I have checked "open" AND "closed" issues and this is not a duplicate

Description

Encountered the following error when trying to run a GitHub Action:

Error: cannot read a block mapping entry; a multiline key may not be an implicit key

Steps to Reproduce

Steps to Reproduce

  1. Add the following YAML configuration to a GitHub Action workflow file:
       name: PR Issue Checker
# Created by @smog-root.
on:
 pull_request:
   types: [opened, edited]

jobs:
 check_pr_details:
   runs-on: ubuntu-latest

   steps:
     - name: Checkout code
       uses: actions/checkout@v2

     - name: Set up Python
       uses: actions/setup-python@v2
       with:
         python-version: '3.x'

     - name: Install dependencies (if needed)
       run: pip install re  # Install Python's regex library (not needed if using built-in)

     - name: Check PR Description and Title
       id: check_pr_details
       run: |
         python -c "
import re
import sys
import os

pr_description = os.getenv('GITHUB_EVENT_PULL_REQUEST_BODY', '')
pr_title = os.getenv('GITHUB_EVENT_PULL_REQUEST_TITLE', '')

# Check if PR description is present
if not pr_description:
   print('PR description is missing.')
   sys.exit(1)

# Check if the PR description contains 'Fixes #<issue-number>'
if not re.search(r'Fixes #[0-9]+', pr_description):
   print('The PR description should include Fixes , Close, Closes, Closed , Fix , Fixed , Resolve , Resolves #<issue-number>.')
   sys.exit(1)

# Check if the PR title starts with FIX, FEAT, or DOC
if not re.match(r'^(Fixes|Close|Closes|Closed|Fix|Fixed|Resolve|Resolves
Resolved)', pr_title):
   print('The PR title should start with Fixes , Close, Closes, Closed , Fix , Fixed , Resolve , Resolves')
   sys.exit(1)

print('PR description and title are valid.')
"
       env:
         GITHUB_EVENT_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }}
         GITHUB_EVENT_PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}

     - name: Output result
       run: echo "All checks passed."

Screenshots

No response

Do you want to work on this issue?

Yes

If "yes" to the above, please explain how you would technically implement this.

Suggested Fix

The error is due to a multi-line string in the Python code block within the run command. This can be fixed by formatting the re.match pattern correctly.

Here’s the corrected YAML configuration:

     name: PR Issue Checker
# Created by @smog-root.
on:
  pull_request:
    types: [opened, edited]

jobs:
  check_pr_details:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.x'

      - name: Install dependencies (if needed)
        run: pip install re  # Install Python's regex library (not needed if using built-in)

      - name: Check PR Description and Title
        id: check_pr_details
        run: |
          python -c "
import re
import sys
import os

pr_description = os.getenv('GITHUB_EVENT_PULL_REQUEST_BODY', '')
pr_title = os.getenv('GITHUB_EVENT_PULL_REQUEST_TITLE', '')

# Check if PR description is present
if not pr_description:
    print('PR description is missing.')
    sys.exit(1)

# Check if the PR description contains 'Fixes #<issue-number>'
if not re.search(r'Fixes #[0-9]+', pr_description):
    print('The PR description should include Fixes , Close, Closes, Closed , Fix , Fixed , Resolve , Resolves #<issue-number>.')
    sys.exit(1)

# Check if the PR title starts with FIX, FEAT, or DOC
if not re.match(r'^(Fixes|Close|Closes|Closed|Fix|Fixed|Resolve|Resolves|Resolved)', pr_title):
    print('The PR title should start with Fixes , Close, Closes, Closed , Fix , Fixed , Resolve , Resolves')
    sys.exit(1)

print('PR description and title are valid.')
"
        env:
          GITHUB_EVENT_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }}
          GITHUB_EVENT_PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}

      - name: Output result
        run: echo "All checks passed."
@BigBang001 BigBang001 added the bug Something isn't working label Nov 12, 2024
Copy link
Contributor

👋 Thanks for opening this issue! We appreciate your contribution. Please make sure you’ve provided all the necessary details and screenshots, and don't forget to follow our Guidelines and Code of Conduct. Happy coding! 🚀

@github-actions github-actions bot added gssoc-ext GSSoC'24 Extended Version hacktoberfest Hacktober Collaboration hacktoberfest-accepted Hacktoberfest 2024 level? labels Nov 12, 2024
@BigBang001 BigBang001 linked a pull request Nov 12, 2024 that will close this issue
@Mayureshd-18 Mayureshd-18 added level1 10 Points 🥇 and removed level? labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working gssoc-ext GSSoC'24 Extended Version hacktoberfest Hacktober Collaboration hacktoberfest-accepted Hacktoberfest 2024 level1 10 Points 🥇
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants