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: found unexpected type for label 'xxx' (should be array of config options) #712

Closed
2 of 5 tasks
HorizonNet opened this issue Dec 6, 2023 · 28 comments
Closed
2 of 5 tasks
Assignees
Labels
bug Something isn't working

Comments

@HorizonNet
Copy link

Description:
After upgrading to v5.0.0 and changing the labeler configuration file matching to what is outlined in the documentation, I'm receiving the following error as soon as the action starts

Run actions/[email protected]
The configuration file (path: .github/labeler.yml) was not found locally, fetching via the api
Error: Error: found unexpected type for label 'terraform' (should be array of config options)
Error: found unexpected type for label 'terraform' (should be array of config options)

Action version:
5.0.0

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Repro steps:
After upgrading to 5.0.0 changed the labeler configuration to

terraform:
  - changed-files:
    - any-glob-to-any-file: terraform/**

which to me looks similar to the example from the documentation

Documentation:
- changed-files:
  - any-glob-to-any-file: docs/*

The workflow is defined as follows and used to work previously

---
name: Pull Request Labeler

on:
  pull_request_target:

jobs:
  triage:
    name: Label triage

    permissions:
      contents: read
      pull-requests: write

    runs-on: ubuntu-22.04

    steps:
      - uses: actions/[email protected]
        with:
          sync-labels: true

Expected behavior:
The action should run successfully.

Actual behavior:
The action is failing with the error provided above.

@MaksimZhukov
Copy link
Contributor

Hello @HorizonNet!
Thank you for reporting this!
We will take a look and contact you as soon as we have any updates!

@PartTimeLegend
Copy link

PartTimeLegend commented Dec 8, 2023

I'm having the same issue.

My config looks like this.

github:
- changed-files:
  - any-glob-to-any-file: .github/*
mergify:
- changed-files:
  - any-glob-to-any-file: .mergify.yml
docker:
- changed-files:
  - any-glob-to-any-file: Dockerfile
license:
- changed-files:
  - any-glob-to-any-file: LICENSE
windows:
- changed-files:
  - any-glob-to-any-file: NewMachineSetup.ps1
  - any-glob-to-any-file: chocolatey.txt
  - any-glob-to-any-file: features.txt
mac:
- changed-files:
  - any-glob-to-any-file: NewMachineSetup.sh
  - any-glob-to-any-file: brews.txt
docs:
- changed-files:
  - any-glob-to-any-file: README.md
  - any-glob-to-any-file: SECURITY.md
python:
- changed-files:
  - any-glob-to-any-file: requirements.txt

@MaksimZhukov
Copy link
Contributor

@HorizonNet could you please provide us with a link to the public repository where the issue occurs?
I could not reproduce your issue. I used the workflow and configuration files that you provided, but everything works as expected (link to the related PR).

@bryannaegele
Copy link

bryannaegele commented Dec 11, 2023

@MaksimZhukov we have this issue with labels in the format of abc/def on internal repos and snake or kebab case on some public ones.

Failed public run
Labeler Config
Workflow

Edit:

Basic ones that are failing.

Error: Error: found unexpected type for label 'elixir' (should be array of config options)
Error: found unexpected type for label 'elixir' (should be array of config options)

Config

elixir:
  - .github/elixir-test-matrix.json
  - instrumentation/**/*.ex
  - instrumentation/**/*.exs
  - instrumentation/**/mix.lock
  - propagators/**/*.ex
  - propagators/**/*.exs
  - propagators/**/mix.lock
  - exporters/**/*.ex
  - exporters/**/*.exs
  - exporters/**/mix.lock
  - examples/**/*.ex
  - examples/**/*.exs
  - examples/**/mix.lock
  - utilities/**/*.ex
  - utilities/**/*.exs
  - utilities/**/mix.lock

@MaksimZhukov
Copy link
Contributor

Thank you @bryannaegele!
I will investigate the issue!

@bryannaegele
Copy link

bryannaegele commented Dec 11, 2023

I don't know if it's just some yaml parsing strictness that's changed. That's all I can think of. Updated comment above with error and example.

@MaksimZhukov
Copy link
Contributor

@bryannaegele you see the error because the configuration file structure was significantly redesigned and is not compatible with the structure of the previous version. Please read the action documentation to find out how to adapt your configuration files for use with the new action version

@bryannaegele
Copy link

Oh, wow. I didn't see that. That's a significant change. Noted. 👍🏻

@mndeveci
Copy link

@MaksimZhukov we are having the same issue as well. Does both action version and its configuration be up to date in the develop/main branch for this to work?

This was my attempt to update configuration, but GHA is still failing

apply-file-based-labels
Error: found unexpected type for label 'area/package' (should be array of config options)

@lamdor
Copy link

lamdor commented Dec 11, 2023

I've also ran into the same issue, but I'm not sure what is correct. The README refers to lists of globs, however, the examples show only a string and not a list. And then the config on #712 (comment) shows multiple items with any-glob-to-any-file. It's confusing.

@MaksimZhukov
Copy link
Contributor

Hello @mndeveci! I am using your configuration file and it works (workflow run, related PR). Could you please check?

Hello @lamdor! Thank you for your comment! We will add more examples to the documentation!

@tautschnig
Copy link

@MaksimZhukov we are having the same issue as well. Does both action version and its configuration be up to date in the develop/main branch for this to work?

Let me echo the above question: which action and labeling configuration files are used upon a run, the ones from the base branch or the ones from the head branch? model-checking/kani#2923 (with GitHub action log https://github.com/model-checking/kani/actions/runs/7131018587/job/19418690999) was my attempt to downgrade to v4, but it would still fail with this error message?! Are we perhaps just facing a transient issue in that we need to accept the failure in the PR that upgrades the config file, and all will be well afterwards?

@bryannaegele
Copy link

@tautschnig pull_request_target event trigger uses the default branch.

@bryannaegele
Copy link

Depending on what your workflows do based on labels, I suggest not permanently using checkout and using what is in the head branch to prevent PRs from causing issues or opening up potential abuse.

@CatChen
Copy link

CatChen commented Dec 22, 2023

I had the same issue. I created a PR that migrates the config from v4 format to v5 format. I changed the triggering event from pull_request_target to pull_request but the job still failed. This resolved my issue but I can't explain why: add - uses: actions/checkout@v4 before - uses: actions/labeler@v5 in the config migration PR.

In theory, using the pull_request event should be enough and checkout isn't needed. actions/labeler@v5 prints out The configuration file (path: .github/labeler.yml) was not found locally, fetching via the api and it should fetch the updated config from the PR's head (instead of base, which usually means main). Adding checkout changes that printout to The configuration file (path: .github/labeler.yml) was found locally, reading from the file and it magically fixed my issue.

After a successful run, removing actions/checkout@v4 doesn't break it. That's really weird.

I looked into the implementation of how actions/labeler@v5 fetches the config from remote and everything looks fine to me. I don't plan to spend more time on this investigation. Maybe this information can help others.

@IvanZosimov
Copy link
Contributor

Hi, all! Thanks for drawing our attention to the issue ❤️ , recently we've merged PR that should clarify the cause of the problem, provide mitigation plan and help to make process of migration clearer. I'm going to close this issue, if you have any additional questions feel free to reach out.

@oerp-odoo
Copy link

After switching from v4 to v5 labeler, it does not seem to be stable and consistent.

Now labeler action randomly fails with:

Error: found unexpected type for label 'documentation' (should be array of config options)

Strangely if I re-run same failed job, it then passes. And most of the time it passes first time, but sometimes just fails randomly with that error..

workflow looks like this:

name: Labeler
on:
  - pull_request_target

jobs:
  triage:
    permissions:
      contents: read
      pull-requests: write
    runs-on: [self-hosted, pool]
    steps:
      - uses: actions/labeler@v5
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"
          sync-labels: true

Config:

---
documentation:
  - changed-files:
      - any-glob-to-any-file:
          - docs/**/*
          - README.rst
ops:
  - changed-files:
      - any-glob-to-any-file:
          - ops/**/*
          - .github/**/*
dev:
  - changed-files:
      - any-glob-to-any-file:
          - src/**/*

P.S. v4 had no such problems.

geyslan added a commit to geyslan/tracee that referenced this issue Apr 15, 2024
Despite the fact that the labeler v5.0.0 demands a different syntax
for the configuration file, it has inconsistent behavior:

actions/labeler#712 (comment)

So, return to the most recent version that works as expected.
geyslan added a commit to aquasecurity/tracee that referenced this issue Apr 15, 2024
Despite the fact that the labeler v5.0.0 demands a different syntax
for the configuration file, it has inconsistent behavior:

actions/labeler#712 (comment)

So, return to the most recent version that works as expected.
@BillyBlaze
Copy link

BillyBlaze commented Nov 4, 2024

After changing pull_request_target to pull_request and some further investigation I was able to fix this, the problem is that it was still using the config v4 file from the base branch, I fixed this in the PR by adding a checkout. After confirming everything worked in my PR I removed the checkout and reverted pull_request to pull_request_target

      - uses: actions/checkout@v4
        with:
          clean: false
          ref: ${{ github.event.pull_request.head.sha }}

@IvanZosimov IvanZosimov removed their assignment Nov 4, 2024
@onkar
Copy link

onkar commented Nov 4, 2024

I am still seeing this issue. Here is what I have:

File .github/labeler.yml:

migrations:
  - changed-files:
    - any-glob-to-any-file: dir1/dir2/group_loader.py
    - any-glob-to-any-file: dir1/dir2/groups.py
    - any-glob-to-any-file: dir1/dir3/**/*
    - any-glob-to-any-file: dir1/dir2/xyz/*

File .github/workflows/labeler.yml:

name: "Pull Request Labeler"
on:
- pull_request

jobs:
  triage:
    permissions:
      contents: read
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
      uses: actions/checkout@v4
      with:
        clean: false
        ref: ${{ github.event.pull_request.head.sha }}
    - uses: actions/labeler@v5
      with:
        repo-token: "${{ secrets.GITHUB_TOKEN }}"
        sync-labels: true

But I see the following error:

Run actions/labeler@v5
  with:
    repo-token: ***
    configuration-path: .github/labeler.yml
    sync-labels: false
    dot: true
The configuration file (path: .github/labeler.yml) was found locally, reading from the file
Error: Error: found unexpected type for label 'migrations' (should be array of config options)
Error: found unexpected type for label 'migrations' (should be array of config options)

Any idea how to fix this?

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