# \[bug?\] Invalid key on object binding

**URL:** <https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [April 19, 2021, 5:20pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763 "2021-04-19T17:20:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 19, 2021, 5:20pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/1 "2021-04-19T17:20:36Z")

</div>

Hello folks,

This is not a game-breaking issue, since everything works correctly (so far), but I really don’t like that little red triangle popping up above my properties. I’d also like to make sure I didn’t do something wrong…  
So here goes:  
This is created by a python script, it’s a dict that has integers as keys.  
The version is 8.1.3

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/3/03c1669f034ad2f569b1e8d802114c4cb30a212d.png)

If I change the key to not be an integer anymore, the problem disappears:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/f/ff20bca2a84a846673f3dc995760b1876648c4a8.png)  
Note that if I only cast to a string, without adding something, the issue remains.

Could someone explain why, or confirm that it is indeed a bug ?

Thanks in advance, you guys have a great day !

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 19, 2021, 5:38pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/2 "2021-04-19T17:38:49Z")

</div>

Numeric keys are painful to access from other contexts, i.e. scripting. If there’s a strictly ordered list of “keys”, is there any reason to not just make this into an array?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 19, 2021, 5:45pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/3 "2021-04-19T17:45:54Z")

</div>

Well, those keys are actually an ID. Here, they’re all nice and ordered, but it might not always be the case.  
Also, this ID is 1-indexed, which messes things up in an array.  
I’ll try making an array with a dummy 0, and maybe figure out something if the case of non-ordinal IDs presents itself.

Still, why does it say invalid key ? Is it to deter people from using numeric keys ?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 19, 2021, 5:49pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/4 "2021-04-19T17:49:25Z")

</div>

Numeric keys are not valid JSON. You could make them strings instead though, e.g. `"1"`, `"2"`, `"3"`, etc…

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 19, 2021, 5:51pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/5 "2021-04-19T17:51:18Z")

</div>

I tried that, but got the same issue.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 19, 2021, 5:52pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/6 "2021-04-19T17:52:53Z")

</div>

I suspect some intermediate layer is ‘detecting’ them as numeric and coercing them, but can you show your script to coerce the keys to strings anyways?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 19, 2021, 5:57pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/7 "2021-04-19T17:57:37Z")

</div>

This is not the original script, which I changed to use an array, but here’s what’s relevant:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/d/2ddd78cd39b6e81fbbd60936f7799a66ec4951ce.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 19, 2021, 5:57pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/8 "2021-04-19T17:57:46Z")

</div>

Maybe you can use a different shape for your data:

```auto
[
    {
        "id": 1,
        "tcu": "[]ZONE2/TCU/TCU4_3"
    },
    {
        "id": 2,
        "tcu": "[]ZONE2/TCU/TCU4_5"
    }
]
```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 19, 2021, 5:59pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/9 "2021-04-19T17:59:53Z")

</div>

I thought of this, but it kinds of defeats the purpose of what I’m trying to do, which is accessing those by indexing on the ID. This is meant to serve as a map.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 19, 2021, 6:02pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/10 "2021-04-19T18:02:03Z")

</div>

Hmm. Well I’m not sure if there’s coercion going on like @paul-griffith mentioned or if the system is trying to save you from constructing a JSON path that is difficult to use.

Even if your keys were `"1"` instead of `1` instead of a normal reference like `foo.1.baz` you’d have to use a more awkward syntax like `foo["1"].baz`. Not sure what’s going on though, maybe Paul will figure it out 🙂

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 19, 2021, 9:02pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/11 "2021-04-19T21:02:56Z")

</div>

I think it’s mostly just the json tree being overzealous with the warning, actually. From what I can tell, the type is preserved as a string pretty well throughout. If you don’t care about the warnings in the editor, it’s probably _reasonably_ safe to ignore…although I would still consider if there’s a different way to do things.

For instance, I set up a simple transform to return a dictionary with numeric strings as keys, and tested the type:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/8/18abb1caff41989d499c55a205360e7ab61d6513.png)

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 20, 2021, 6:24am UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/12 "2021-04-20T06:24:53Z")

</div>

But you still get the warnings… Why would I convert to strings if it doesn’t get rid of the warnings and if it’s functionally the same ?

Things is, in this particular case, I could make it an array, make a dummy 0, and handle cases where the keys aren’t as neatly and linearly ordered. But I do have another case with the same problem, but In a more complex structure - which is why I presented this simpler case - that cannot be made into an array, and in which keys still need to be numeric values - it’s a dict of dicts of lists, which I could make a list of dicts of lists, but I still need that inner dict to keep its numeric keys…

Well, I guess I’ll just ignore those few warnings and see where that gets me. If problems arise, then I’ll try to figure something…

Thanks for your help folks

---

<div class="post-metadata">

**Author:** ![justin.brzozoski](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justin.brzozoski/32/13452_2.png) [@justin.brzozoski](https://forum.inductiveautomation.com/u/justin.brzozoski)\
**Post date:** [September 9, 2021, 2:11pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/13 "2021-09-09T14:11:51Z")

</div>

Sorry to resurrect an older topic, but this thread was almost exactly my issue, and I still have a few questions.

I’m on Ignition 8.1.7 and am getting lots of “Invalid Key” warnings in Designer. Thanks to this thread, I’ve narrowed it down to object keys that have spaces in them or start with numerals (0-9). In my case, they are the column names for the data of a Perspective table, so I have hundreds of warnings (e.g. 10 columns by 40 rows = 400 warnings).

One complaint I have is that Designer doesn’t seem to be highlighting which keys are causing the warning for me (most of the time). After working in Designer for 30+ minutes it randomly popped up the highlighting of bad keys _once_ for me, and then I came back and noticed that they were also highlighted in the screenshots of this thread. But then my highlighting disappeared and hasn’t come back since.

My bigger question: will using with these invalid keys in a Perspective data table actually cause any issues other than the warning? I need the spaces and numerals in the column names since that’s how they need to be displayed, and the idea of dynamically building a `columns` property just to map from “valid” key names to column names seems excessive. Everything _seems_ to be working right now other than the warning.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [September 9, 2021, 2:22pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/14 "2021-09-09T14:22:35Z")

</div>

welh using spaces and numbers makes it harder to use `this.props.data.data field` but you can still do `this.props.data['data field']`  
i dont think there actually is any other real problem with it tho i guess. apart from cluttering the logs and maybe a slight reduce in performance in the designer because of it xd

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 9, 2021, 2:28pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/15 "2021-09-09T14:28:55Z")

</div>

I don’t know if that can apply to your situation, but I ended up ditching that system and using a list of objects of this sort:

```python
[
  {
    'name': x,
    'id': x,
    'data', x
  },
  {
    'name': y,
    'id': y,
    'data', y
  },
  etc
]

```

This requires an additional (simple) step in the processing, but at least it complies with json rules and got rid of the warnings.

Another solution would be to prefix your ids with a string. Doesn’t help with spaces though, but i’d stick that in a `name` property or something that you access with an id or something.  
It’s less convenient but it’s probably ‘cleaner’

---

<div class="post-metadata">

**Author:** ![justin.brzozoski](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justin.brzozoski/32/13452_2.png) [@justin.brzozoski](https://forum.inductiveautomation.com/u/justin.brzozoski)\
**Post date:** [September 9, 2021, 2:48pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/16 "2021-09-09T14:48:06Z")

</div>

> [@victordcq](#):
>
> welh using spaces and numbers makes it harder to use `this.props.data.data field` but you can still do `this.props.data['data field']`

My data is being used only for output in the table view. I don't actually need to reference it any other way, so the awkward keying doesn't affect me.

> [@pascal.fragnoud](#):
>
> I don’t know if that can apply to your situation, but I ended up ditching that system and using a list of objects of this sort:

I can't alter the basic structure since I have to match the expectations of the [Perspective table component](https://forum.inductiveautomation.com/t/feedback-new-perspective-table/21199). I did consider "mangling" the names in the data table, but I need them to display properly, so that would require I generate a dynamic `columns` property to map names for the user display.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 9, 2021, 2:57pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/17 "2021-09-09T14:57:39Z")

</div>

> [@justin.brzozoski](#):
>
> I can’t alter the basic structure since I have to match the expectations of the [Perspective table component](https://forum.inductiveautomation.com/t/feedback-new-perspective-table/21199).

You can, you just need to process the data in the binding on your table.

```python
    return [data['name'] for data in value.values()]

```

in a script transform for example.

---

<div class="post-metadata">

**Author:** ![justin.brzozoski](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justin.brzozoski/32/13452_2.png) [@justin.brzozoski](https://forum.inductiveautomation.com/u/justin.brzozoski)\
**Post date:** [September 9, 2021, 3:38pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/18 "2021-09-09T15:38:14Z")

</div>

> [@pascal.fragnoud](#):
>
> You can, you just need to process the data in the binding on your table.

Oh, I know _how_ to do the conversion you mentioned, my problem is that the data is being fed into the [Perspective table component](https://docs.inductiveautomation.com/display/DOC81/Perspective+-+Table) and that component doesn't look for column names under the `name` key of the cells.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 9, 2021, 3:45pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/19 "2021-09-09T15:45:35Z")

</div>

Yes, that’s why you process your data to format it in a way the table component understands.  
Except, instead of formatting it where you data is stored, you format it in a transform in your binding on your table’s data property. So it’s not a `name` key anymore.

An alternative solution could be to store your data as a dataset directly, so that your table could use it. You shouldn’t have key issues with a dataset.

---

<div class="post-metadata">

**Author:** ![justin.brzozoski](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justin.brzozoski/32/13452_2.png) [@justin.brzozoski](https://forum.inductiveautomation.com/u/justin.brzozoski)\
**Post date:** [September 9, 2021, 3:53pm UTC](https://forum.inductiveautomation.com/t/bug-invalid-key-on-object-binding/45763/20 "2021-09-09T15:53:30Z")

</div>

> [@pascal.fragnoud](#):
>
> format it in a transform in your binding on your table’s data property. So it’s not a `name` key anymore.

The issue is that these names are the strings that I want the table to display as the column headers (numerals and spaces and all). And they HAVE to be used as keys in the `data` object unless I want to use safely-mangled key names in the data table and then generate a dynamic `columns` table property to map them all back to the headers I want to show. I'm quite sure at this point that the dynamic `columns` is the only way to do this without Designer warnings, but it all _seems_ to be working even with the designer warnings. My big question wasn't "how do I avoid these warnings" it was "is something going to break if I ignore these warnings".

> [@pascal.fragnoud](#):
>
> An alternative solution could be to store your data as a dataset directly, so that your table could use it. You shouldn’t have key issues with a dataset.

This whole thing used to be a dataset and worked beautifully. I converted away since I wanted per-cell styling and coloring. ☹
