# Exception caught while applying mutate filter {:exception=\>"Could not set field 'product' on object 'x' to value 'y'.This is probably due to trying to set a field like \[foo\]\[bar\] = someValuewhen \[foo\] is not either a map or a string"}

**URL:** https://discuss.elastic.co/t/exception-caught-while-applying-mutate-filter-exception-could-not-set-field-product-on-object-x-to-value-y-this-is-probably-due-to-trying-to-set-a-field-like-foo-bar-somevaluewhen-foo-is-not-either-a-map-or-a-string/351707
**Category:** Logstash
**Created:** [January 24, 2024, 12:19pm UTC](https://discuss.elastic.co/t/exception-caught-while-applying-mutate-filter-exception-could-not-set-field-product-on-object-x-to-value-y-this-is-probably-due-to-trying-to-set-a-field-like-foo-bar-somevaluewhen-foo-is-not-either-a-map-or-a-string/351707 "2024-01-24T12:19:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mwitsas](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mwitsas](https://discuss.elastic.co/u/mwitsas)
#### Post date: [January 24, 2024, 12:19pm UTC](https://discuss.elastic.co/t/exception-caught-while-applying-mutate-filter-exception-could-not-set-field-product-on-object-x-to-value-y-this-is-probably-due-to-trying-to-set-a-field-like-foo-bar-somevaluewhen-foo-is-not-either-a-map-or-a-string/351707/1 "2024-01-24T12:19:07Z")

</div>

When attempting to rename fields as in the following example:

```auto
  mutate {
    rename => {
      "vendor" => "[abc][vendor]"
      "vendor_product" => "[abc][vendor][product]"
      "vendor_product_version" => "[abc][vendor][product][version]"
   }
 }

```

I get the following error:

`[2024-01-24T12:07:47,506][WARN][logstash.filters.mutate][test-pipeline][ecb4213a79da96df1d34665b2fe43c7b255995e3af6e5ac336ef36beda368532] Exception caught while applying mutate filter {:exception=>"Could not set field 'product' on object 'abc' to value 'def ghi'.This is probably due to trying to set a field like [foo][bar] = someValuewhen [foo] is not either a map or a string"}`

I have seen a couple of other posts around this error suggesting the field [abc][vendor] is a string and not an object at the point the subfield is assigned, but have not been able to figure the solution out.

Any help appreciated!

---

<div class="post-metadata">

### Author: ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)
#### Post date: [January 24, 2024, 1:22pm UTC](https://discuss.elastic.co/t/exception-caught-while-applying-mutate-filter-exception-could-not-set-field-product-on-object-x-to-value-y-this-is-probably-due-to-trying-to-set-a-field-like-foo-bar-somevaluewhen-foo-is-not-either-a-map-or-a-string/351707/2 "2024-01-24T13:22:41Z")

</div>

> [@mwitsas](#):
>
> I have seen a couple of other posts around this error suggesting the field [abc][vendor] is a string and not an object at the point the subfield is assigned, but have not been able to figure the solution out.

What you are trying to do is not possible, you need to change the fields names, you can't mix strings and objects in the same field like you are doing.

You need something like this:

```auto
mutate {
  rename => {
    "vendor" => "[abc][vendor][vendor_name]"
    "vendor_product" => "[abc][vendor][product_name]"
    "vendor_product_version" => "[abc][vendor][product_version]"
  }
}

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 21, 2024, 1:23pm UTC](https://discuss.elastic.co/t/exception-caught-while-applying-mutate-filter-exception-could-not-set-field-product-on-object-x-to-value-y-this-is-probably-due-to-trying-to-set-a-field-like-foo-bar-somevaluewhen-foo-is-not-either-a-map-or-a-string/351707/3 "2024-02-21T13:23:23Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
