Unexpected executor invocation format

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:

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:

$ 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 >>

:wave: 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.

I suggest the following code:

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.

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:

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:

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

Hi @martinssipenko,

The error you’re getting:

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:

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:

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"

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

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