# Unexpected executor invocation format

**URL:** <https://discuss.circleci.com/t/unexpected-executor-invocation-format/41480>\
**Category:** Bug Reports\
**Created:** [October 8, 2021, 3:35pm UTC](https://discuss.circleci.com/t/unexpected-executor-invocation-format/41480 "2021-10-08T15:35:05Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinssipenko](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/martinssipenko/32/2895_2.png) [@martinssipenko](https://discuss.circleci.com/u/martinssipenko)\
**Post date:** [October 8, 2021, 3:35pm UTC](https://discuss.circleci.com/t/unexpected-executor-invocation-format/41480/1 "2021-10-08T15:35:05Z")

</div>

I’m trying to create an orb with a job to which an executor could be passed using parameters, but I’m getting an “Unexpected executor invocation format” error when running orb validate command.

I was able to achieve what I desired in a different way by passing tag as an executor argument in workflow, however, doing so requires to also specify the executor name in the workflow which I’d like to avoid as I would like default to be used.

I’ve created the following example orb that has the issue I’m facing:

```auto
version: 2.1

executors:
  php-executor:
    parameters:
      tag:
        type: string
        default: latest
    docker:
      - image: php:<< parameters.tag >>

jobs:
  build:
    parameters:
      executor:
        type: executor
        default: php-executor
      tag:
        type: string
        default: latest
    executor:
      name: << parameters.executor >>
      tag: << parameters.tag >>
    steps:
      - checkout

```

The full error message:

```auto
$ circleci orb --skip-update-check validate orb.yml 
Error: Error calling job: 'php-test'
Unexpected executor invocation format
The value of `name` must be a string
Examples of correct executor invocation:
  executor: string-executor-name
  executor: {name: string-executor-name}
  executor: << parameters.executor-type-parameter >>

```

---

<div class="post-metadata">

**Author:** ![yannCI](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/yannci/32/24866_2.png) [@yannCI](https://discuss.circleci.com/u/yannCI)\
**Post date:** [October 8, 2021, 10:39pm UTC](https://discuss.circleci.com/t/unexpected-executor-invocation-format/41480/2 "2021-10-08T22:39:02Z")

</div>

👋 Hello @martinssipenko, and welcome to the CircleCI Discuss community!

I believe the issue stems the use of `executor` --which is a reserved keyword-- as the parameter name.

Also, as stated in the other error message, the value given to `name` must be a string.

Furthermore, if you want to have the tag you specify as a job parameter passed to the `executor` parameter, and the into the reusable executor you declared, you’ll need to use [“pass-through” parameters](https://circleci.com/docs/2.0/orbs-best-practices/#consider-pass-through-parameters).

I suggest the following code:

```auto
version: 2.1

executors:
  php-executor:
    parameters:
      tag:
        type: string
        default: latest
    docker:
      - image: php:<< parameters.tag >>

jobs:
  build:
    parameters:
      my-executor:
        type: string
        default: php-executor
      version:
        type: string
        default: latest
    executor:
      name: <<parameters.my-executor>>
      tag: <<parameters.version>>
    steps:
      - checkout

```

Let me know if this helps.

---

<div class="post-metadata">

**Author:** ![martinssipenko](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/martinssipenko/32/2895_2.png) [@martinssipenko](https://discuss.circleci.com/u/martinssipenko)\
**Post date:** [October 9, 2021, 9:19am UTC](https://discuss.circleci.com/t/unexpected-executor-invocation-format/41480/3 "2021-10-09T09:19:16Z")

</div>

Hello @yannCI , thank you for your answer.

I actually have tried the option you suggested before I opened this discussion, and it did not work for me.

When trying to validate the orb I’m getting the following error:

```auto
circleci orb --skip-update-check validate orb.yml
Error: Error calling job: 'build'
Cannot find a definition for executor named TEST_STRING

```

My `orb.yaml` file contents are:

```auto
version: 2.1

executors:
  php-executor:
    parameters:
      tag:
        type: string
        default: latest
    docker:
      - image: php:<< parameters.tag >>

jobs:
  build:
    parameters:
      my-executor:
        type: string
        default: php-executor
      version:
        type: string
        default: latest
    executor:
      name: <<parameters.my-executor>>
      tag: <<parameters.version>>
    steps:
      - checkout

```

---

<div class="post-metadata">

**Author:** ![yannCI](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/yannci/32/24866_2.png) [@yannCI](https://discuss.circleci.com/u/yannCI)\
**Post date:** [October 11, 2021, 10:21pm UTC](https://discuss.circleci.com/t/unexpected-executor-invocation-format/41480/4 "2021-10-11T22:21:18Z")

</div>

Hi @martinssipenko,

The error you’re getting:

```auto
Cannot find a definition for executor named TEST_STRING

```

indicates that you’re trying to call the `build` job declared in your config as follows:

```auto
workflows:
  my-wkfw:
    jobs:
      - build:
          my-executor: TEST_STRING

```

There is no executor defined with the name `TEST_STRING`, hence the error you’re getting.

Here’s another example of a valid `config.yml`:

```auto
version: 2.1

executors:
  php-executor:
    parameters:
      tag:
        type: string
        default: latest
    docker:
      - image: php:<< parameters.tag >>

  ruby-executor:
    parameters:
      tag:
        type: string
        default: latest
    docker:
      - image: ruby:<< parameters.tag >>

jobs:
  build:
    parameters:
      my-executor:
        type: string
        default: php-executor
      version:
        type: string
        default: latest
    executor:
      name: <<parameters.my-executor>>
      tag: <<parameters.version>>
    steps:
      - checkout

workflows:
  my-wkfw:
    jobs:
      - build:
          name: Ruby build
          my-executor: ruby-executor

      - build:
          name: PHP build
          version: "8.0"

```

---

<div class="post-metadata">

**Author:** ![martinssipenko](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/martinssipenko/32/2895_2.png) [@martinssipenko](https://discuss.circleci.com/u/martinssipenko)\
**Post date:** [October 13, 2021, 10:16am UTC](https://discuss.circleci.com/t/unexpected-executor-invocation-format/41480/5 "2021-10-13T10:16:10Z")

</div>

@yannCI I’m defining this executor in Orb where I do not have any workflows defined.

---

<div class="post-metadata">

**Author:** ![martinssipenko](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/martinssipenko/32/2895_2.png) [@martinssipenko](https://discuss.circleci.com/u/martinssipenko)\
**Post date:** [October 15, 2021, 5:45am UTC](https://discuss.circleci.com/t/unexpected-executor-invocation-format/41480/6 "2021-10-15T05:45:18Z")

</div>

@yannCI I believe CiecleCI CLI does a GraphQL request to API for Orb validation that returns this error.

---

<div class="post-metadata">

**Author:** ![relaxdiego](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/relaxdiego/32/28083_2.png) [@relaxdiego](https://discuss.circleci.com/u/relaxdiego)\
**Post date:** [February 23, 2022, 6:28am UTC](https://discuss.circleci.com/t/unexpected-executor-invocation-format/41480/7 "2022-02-23T06:28:45Z")

</div>

Hi, so what was the resolution to this? I’m getting the same error and there’s no “TEST-STRING” anywhere in my orb.yml file. Also, I’m getting this error when I run `circleci orb publish` and not when I’m executing any workflow.

---

<div class="post-metadata">

**Author:** ![ranrubin](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/ranrubin/32/30802_2.png) [@ranrubin](https://discuss.circleci.com/u/ranrubin)\
**Post date:** [September 6, 2022, 9:29am UTC](https://discuss.circleci.com/t/unexpected-executor-invocation-format/41480/8 "2022-09-06T09:29:44Z")

</div>

@martinssipenko did you manage to resolve this? I’m having the same issue

---

<div class="post-metadata">

**Author:** ![0xabdi](https://avatars.discourse-cdn.com/v4/letter/0/65b543/32.png) [@0xabdi](https://discuss.circleci.com/u/0xabdi)\
**Post date:** [November 29, 2022, 1:14pm UTC](https://discuss.circleci.com/t/unexpected-executor-invocation-format/41480/9 "2022-11-29T13:14:09Z")

</div>

> [@yannCI](#):
>
> ```auto
> version: 2.1
> 
> executors:
> php-executor:
> parameters:
> tag:
> type: string
> default: latest
> docker:
> - image: php:<< parameters.tag >>
> 
> jobs:
> build:
> parameters:
> my-executor:
> type: string
> default: php-executor
> version:
> type: string
> default: latest
> executor:
> name: <<parameters.my-executor>>
> tag: <<parameters.version>>
> steps:
> - checkout
> 
> ```

@martinssipenko How did you go about resolving this?

I am also getting `Cannot find a definition for executor named TEST_STRING` when I try to pass executor parameters in an orb.

---

<div class="post-metadata">

**Author:** ![EricRibeiroCCI](https://avatars.discourse-cdn.com/v4/letter/e/f475e1/32.png) [@EricRibeiroCCI](https://discuss.circleci.com/u/EricRibeiroCCI)\
**Post date:** [December 21, 2022, 11:06pm UTC](https://discuss.circleci.com/t/unexpected-executor-invocation-format/41480/10 "2022-12-21T23:06:04Z")

</div>

Hey folks 👋

If I understood correctly, you are trying to pass the executor name and the executor parameters as arguments to a job in an orb:

```auto
jobs:
  build:
    ...
    parameters:
      executor:
        type: executor
        default: php-executor
      tag:
        type: string
        default: latest
    executor:
      name: << parameters.executor >> # ❌ not supported
      tag: << parameters.tag >>

```

Unfortunately, we do not support this. When it comes to executors in an orb config, there are two approaches to follow:

**A) Get the executor as a parameter**

```auto
jobs:
  build:
    ...
    parameters:
      executor:
        type: executor
        default: php-executor
    executor: << parameters.executor >>

```

**B) Hard-code the executor and get its parameters**

```auto
jobs:
  build:
    ...
    parameters:
      tag:
        type: string
        default: latest
    executor:
      name: php-executor
      tag: << parameters.tag >>

```

**B** doesn’t offer a lot of flexibility. **A** , however, lets you receive the executor and its parameters as arguments. But as mentioned before, this occurs at the workflow level, outside the orb:

### my-orb.yml:

```auto
version: 2.1
...
executors:
  php-executor:
    parameters:
      tag:
        type: string
        default: latest
    docker:
      - image: php:<< parameters.tag >>

jobs:
  build:
    parameters:
      executor:
        type: executor
        default: php-executor
    executor: << parameters.executor >>
    steps:
      - checkout

```

Notice how there is no tag parameter in the build job, but we can still pass it as an argument to the executor in the workflow:

### .cicleci/config.yml:

```auto
version: 2.1

orbs: 
  my-orb: my-namespace/my-orb@1.0

workflows:
  build:
    jobs:
      - my-orb/build:
          executor: 
            name: php-executor
            tag: 7.2

```

Admittedly having the executor name as a parameter would make things easier, but it’s not possible at the moment. If you want to explore complex examples of the concept I shared above, I recommend looking at [this](https://github.com/game-ci/unity-orb) orb. You can find its executors [here](https://github.com/game-ci/unity-orb/tree/main/src/executors), jobs [here](https://github.com/game-ci/unity-orb/tree/main/src/jobs) and a real-world example using it [here](https://github.com/CircleCI-Public/Unity2D-Demo-Game-CI-CD/blob/main/.circleci/config.yml).

I hope this helps!

---

<div class="post-metadata">

**Author:** ![surya](https://avatars.discourse-cdn.com/v4/letter/s/8e8cbc/32.png) [@surya](https://discuss.circleci.com/u/surya)\
**Post date:** [November 21, 2023, 6:52pm UTC](https://discuss.circleci.com/t/unexpected-executor-invocation-format/41480/11 "2023-11-21T18:52:21Z")

</div>

This is gold. I easily would have wasted 2-3 days of my time trying to crack this.  
Can we please update this in some of the official circleci documentation? Would be very very usesful.

**Ways to pass executor as parameter**

Thanks a lot Eric 🙇‍♀️  
You are a hero!
