Code & QA Zone: Tutorials, Tools, Guides & Tips for Developers & Testers

How to Fix data types don't match (LIST:MAP) Error in Karate DSL

If you happen to run into the “data types don’t match (LIST:MAP)” error while validating schemas in Karate DSL, this post is for you.

We’ll break down why this occurs and how to fix it in seconds.

The Problem: Why Is My Test Failing?

Imagine you have an endpoint that returns a list of objects, such as the following JSON:

[
  {
    "id": 123,
    "name": "some name",
    "date_from": "2026-04-12"
  }
]

And you define your validation schema like this:

* def expectedSchema = { id: '#number', name: '#string', date_from: '#string' }
And match response == expectedSchema

When executed, Karate will throw the following error: match failed: EQUALS $ | data types don’t match (LIST:MAP)

data types don't match (LIST:MAP) Error

The Root Cause

The error is very literal once you understand Karate’s terminology:

  • LIST: This is the array returned by your API (identified by the square brackets []).
  • MAP: This is the single object you defined in your expectedSchema variable (identified by the curly braces {}).

Karate is trying to compare a collection of objects against a single object template, and logically, the structural types do not align.

The Solution: 3 Ways to Fix It

This is the most readable approach. You are telling Karate to apply the schema validation to every individual element within the array.

And match each response == expectedSchema

2. Defining the Schema as an Array (#[])

If you prefer to validate that the entire response is an array containing that specific object type in a single line:

And match response == '#[] expectedSchema'

Validate list using single object schema - FIXED

3. Validation by Index

If you are dealing with responses containing thousands of records and want to avoid the performance overhead of iterating through every single one, you can validate just the first element:

# Fast and reliable for large datasets
And match response[0] == expectedSchema

Wrap Up

The LIST:MAP error is just Karate’s way of saying: “You gave me a bucket of items, but told me to look for a single one.”

Pick the approach that fits you better:

  • Small list? Use match each or #[].
  • Huge list? Stick to response[0] to keep your CI/CD pipeline moving fast.

Happy testing!