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 · 26 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/labeler@v5.0.0
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/labeler@v5.0.0
        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.

@Borda
Copy link

Borda commented Dec 13, 2023

@Borda Based on my tests and what I've seen so far, also the config needs to be in the default branch.

so it means that for debugging we need to temporally switch to the pull_request and before merging revert to pull_request_target

@HorizonNet
Copy link
Author

@Borda Based on my tests and what I've seen so far, also the config needs to be in the default branch.

so it means that for debugging we need to temporally switch to the pull_request and before merging revert to pull_request_target

Can't tell as I haven't switched the trigger. In my case it was easier/better to bypass branch protection once.

@FranzForstmayr
Copy link

FranzForstmayr commented Dec 13, 2023

I missed the checkout action (https://github.com/scikit-rf/scikit-rf/blob/06190acd59d7be77e7907b45456ffecba66dfd1d/.github/workflows/PR_labeler.yml#L9) in our configuration yml file before, that's why the old labeler.yml file was used all the time.

This is visible through this line in the logs.

The configuration file (path: .github/labeler.yml) was not found locally, fetching via the api

So I ended up deleting the whole workflow (scikit-rf/scikit-rf#985), labeler still failed as there was no checkout task. After merging to master I re enabled the PR labeler from scratch (scikit-rf/scikit-rf#986).

sverweij added a commit to sverweij/virtual-code-owners that referenced this issue Dec 13, 2023
…abeler.yml - BREAKING (#163)

## Description

- changes the --emitLabeler output so it supports the labeler v5 format

## Motivation and Context

actions/labeler [changed their configuration format in a breaking
fashion](actions/labeler#712)


## How Has This Been Tested?

- [x] green ci
- [x] updated non-regression tests
- [x] generating a labeler.yml and running it against the new version of
actions/labeler - see [action run
7194463872](https://github.com/sverweij/virtual-code-owners/actions/runs/7194463872/job/19595044485?pr=163)

## Types of changes

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Documentation only change
- [ ] Refactor (non-breaking change which fixes an issue without
changing functionality)
- [x] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing
functionality to change)
@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.
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