# "Unable to find key" warnings in CanJS 4.0

**URL:** <https://forums.bitovi.com/t/unable-to-find-key-warnings-in-canjs-4-0/906>\
**Category:** CanJS\
**Created:** [June 5, 2018, 2:58pm UTC](https://forums.bitovi.com/t/unable-to-find-key-warnings-in-canjs-4-0/906 "2018-06-05T14:58:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phillipskevin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/phillipskevin/32/102_2.png) [@phillipskevin](https://forums.bitovi.com/u/phillipskevin)\
**Post date:** [June 5, 2018, 2:58pm UTC](https://forums.bitovi.com/t/unable-to-find-key-warnings-in-canjs-4-0/906/1 "2018-06-05T14:58:09Z")

</div>

In recent versions of CanJS, we have updated the warnings that are given if `can-stache` can’t find a key you are trying to use. If you have recently upgraded CanJS, you’ve probably seen warnings like these:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/donejs/original/1X/e040b713b9241bec91ea9d3ca53faa85fe6a24b4.png)

This post will try to explain what causes these warnings and how to fix them.

There are a few different things that cause these warnings:

## Attempted scope walking

If the warning you see contains suggestions for a “correct” key to replace what you are using, it probably means you are accidentally trying to walk the scope. These warnings look like this:

![image](https://canada1.discourse-cdn.com/flex035/uploads/donejs/optimized/1X/33a808acd2b44bfbc598d91b1ccf759f7ec60acc_2_690x57.png)

In CanJS 4.0, we removed the ability to walk up the scope to find a key, but we are trying to let you know this (in development) so that you can fix places where you’re still doing this.

For these warnings, you probably just want to pick the correct suggestion from the given options and use that in your code instead.

## Typos

The simplest cause for warnings _without_ suggestions is typos:

> MyAppView:2: Unable to find key “tittle”.

Did you type `{{tittle}}` instead of `{{title}}` like I did? This one is an easy fix.

## Properties that are only “sometimes” defined

A situation that is a little more difficult to diagnose is warnings for properties that are correct, but don’t exist all the time.

For example,

> MyAppView:2: Unable to find key “first”.

is caused by this code:

```auto
{{# each(people) }}
    {{message}}, {{tittle}} {{first}} {{last}}!
{{/ each }} 

```

because not all the `people` have a `first` property:

```auto
people: {
    default() {
        return [{
            title: "Mr",
            first: "Emmet",
            last: "Brickowoski"
        }, {
            title: "Ms",
            first: "Wyldstyle"
        }, {
            title: "Lord",
            last:"Business"
        }];
    }
}

```

This can be fixed by making sure all the properties your template is using are defined. You can do this by filling them in with values:

```auto
people: {
    default() {
        return [{
            title: "Mr",
            first: "Emmet",
            last: "Brickowoski"
        }, {
            title: "Ms",
            first: "Wyldstyle",
            last: ""
        }, {
            title: "Lord",
            first: "",
            last:"Business"
        }];
    }
}

```

This can be time consuming and is very difficult if this is data coming from an API, so a better solution is to use observables that specifiy which keys exist. In this example this can be done by defining the `People` and `Person` types:

```auto
const Person = DefineMap.extend({
    title: "string",
    first: "string",
    last: "string"
});

const People = DefineList.extend({
    "#": Person
});

```

And then setting the `people` `Type`:

```auto
people: {
    Type: People,
    default() {
        return [...];
    }
}

```

This makes sure that each item in the `people` array is a `Person`, which has the definitions for all of the properties we are using.

This same technique will work with any observable that implements `canReflect.hasKey`.

## Other Warnings?

Are you seeing warnings that don’t fit in one of the categories above? Please let us know with a comment below or an issue in [can-stache](https://github.com/canjs/can-stache/issues/new).
