Expected type: Mapping, found: String Error

I have this error, I’m new to CircleCi and YAML and I got this error

#!/bin/sh -eo pipefail
# ERROR IN CONFIG FILE:
# [#/jobs/run_unit_tests_job] only 1 subschema matches out of 2
# 1. [#/jobs/run_unit_tests_job/steps/3] 0 subschemas matched instead of one
# |   1. [#/jobs/run_unit_tests_job/steps/3] expected type: Mapping, found: String
# |   |   SCHEMA:
# |   |     type: object
# |   |   INPUT:
# |   |     null
# |   2. [#/jobs/run_unit_tests_job/steps/3] Input not a valid enum value
# |   |   Steps without arguments can be called as strings
# |   |     enum:
# |   |     - checkout
# |   |     - setup_remote_docker
# |   |     - add_ssh_keys
# 
# -------

and here’s my config.yaml
version: 2.1

references:
  gradle_key: &gradle_key
                jars-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "build.gradle.kts" }}-{{ checksum "app/build.gradle.kts" }}

executors:
  android-executor:
    working_directory: /home/circleci/project
    docker:
      - image: circleci/android:api-30
    environment:
      _JAVA_OPTIONS: "-Xmx2048m -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
      GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError" -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false'


commands:

  prepare_build:
    steps:
      - checkout
      - restore_gradle_cache
      - load_android_dependencies
      - save_cache

  execute_unit_tests:
    steps:
      - run:
          name: Run unit tests
          command: ./gradlew lint test
      - store_artifacts_test_results

  restore_gradle_cache:
    description: Restore Android Gradle build cache
    steps:
      - restore_cache:
          key: *gradle_key

  load_android_dependencies:
    description: Download Android Dependencies
    steps:
      - run:
          name: Download Android Dependencies
          command: ./gradlew androidDependencies

  save_gradle_cache:
    steps:
      - save_cache:
          key: *gradle_key
          paths:
            - ~/.gradle


  store_artifacts_test_results:
    description: Store Artifacts reports & Test results
    steps:
      - store_artifacts:
          path: app/build/reports/
          destination: /reports/
      - store_test_results:
          path: app/build/test-results/
          destination: /test-results/

jobs:
  run_unit_tests_job:
    executor: android-executor
    steps:
      - prepare_build
      - execute_unit_tests

workflows:
  run_all_unit_tests:
    jobs:
      - run_unit_tests_job

Hi @MohamedISoliman,

Welcome to the CircleCI community!

I believe the issue stems from the save_cache step in the declaration of the prepare_build reusable command.

A save_cache step always requires the key key.

That said, my guess is that, in the declaration of the prepare_build command, you specified save_cache instead of the save_gradle_cache command you declared further down.

I can confirm that after replacing save_cache with save_gradle_cache, I was able to successfully validate the configuration file using the CircleCI CLI.

Let me know if this helps.