# Ttn-lw-migrate fails on extra fields

**URL:** <https://www.thethingsnetwork.org/forum/t/ttn-lw-migrate-fails-on-extra-fields/50292>\
**Category:** Migrating Devices to V3\
**Created:** [August 2, 2021, 12:43pm UTC](https://www.thethingsnetwork.org/forum/t/ttn-lw-migrate-fails-on-extra-fields/50292 "2021-08-02T12:43:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![wotan](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/wotan/32/36850_2.png) [@wotan](https://www.thethingsnetwork.org/forum/u/wotan)\
**Post date:** [August 2, 2021, 12:43pm UTC](https://www.thethingsnetwork.org/forum/t/ttn-lw-migrate-fails-on-extra-fields/50292/1 "2021-08-02T12:43:24Z")

</div>

I’ve defined some extra fields in my devices  
“attributes”: {  
“deepness”: attr[‘Deepness’],  
“dev\_id\_knd”: attr[‘DevIdKnd’]

What’s getting me in trouble now with ttn-lw-migrate obviously checking the attributes:

./ttn-lw-migrate devices --dry-run --verbose --source ttnv2 “137-1” --ttnv2.with-session=false \> devices.json  
[…]  
field=attributes[dev\_id\_knd]  
reason=value does not match regex pattern “^a-z0-9{2,}$”  
name=EndDeviceValidationError

Is there any way to teach ttn-lw-migrate the new fields?  
And are private fields possible in v3 any more?

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [August 2, 2021, 1:28pm UTC](https://www.thethingsnetwork.org/forum/t/ttn-lw-migrate-fails-on-extra-fields/50292/2 "2021-08-02T13:28:48Z")

</div>

> [@wotan](#):
>
> Is there any way to teach ttn-lw-migrate the new fields?

The field names have to match the regex pattern - there is no underscore in there.

There are your own attributes on the General Settings page for a device.

What’s not clear is if you are getting them from the migration tool.

---

<div class="post-metadata">

**Author:** ![wotan](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/wotan/32/36850_2.png) [@wotan](https://www.thethingsnetwork.org/forum/u/wotan)\
**Post date:** [August 2, 2021, 1:48pm UTC](https://www.thethingsnetwork.org/forum/t/ttn-lw-migrate-fails-on-extra-fields/50292/3 "2021-08-02T13:48:20Z")

</div>

> [@descartes](#):
>
> The field names have to match the regex pattern - there is no underscore in there.

dev\_id, app\_eui, dev\_eui, app\_key, … all contain underscores, don’t they?

> [@descartes](#):
>
> What’s not clear is if you are getting them from the migration tool.

And if they are imported regularly.

> [@descartes](#):
>
> There are your own attributes on the General Settings page for a device.

Thank you. Found it.

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [August 2, 2021, 2:46pm UTC](https://www.thethingsnetwork.org/forum/t/ttn-lw-migrate-fails-on-extra-fields/50292/4 "2021-08-02T14:46:28Z")

</div>

> [@wotan](#):
>
> dev\_id, app\_eui, dev\_eui, app\_key, … all contain underscores, don’t they?

Yes, yes they do. I’m not sure how that helps.

> [@wotan](#):
>
> And if they are imported regularly.

I don’t understand what this means - I’ve used the migration tool and I’ve not seen any custom fields available from the v2 console.

---

<div class="post-metadata">

**Author:** ![wotan](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/wotan/32/36850_2.png) [@wotan](https://www.thethingsnetwork.org/forum/u/wotan)\
**Post date:** [August 2, 2021, 3:36pm UTC](https://www.thethingsnetwork.org/forum/t/ttn-lw-migrate-fails-on-extra-fields/50292/5 "2021-08-02T15:36:26Z")

</div>

> [@descartes](#):
>
> Yes, yes they do. I’m not sure how that helps.

I don’t understand why  
reason=value does not match regex pattern “^a-z0-9{2,}$”  
doesn’t get triggered by dev\_id field name as dev\_id\_knd triggers the error.

> [@descartes](#):
>
> I’ve not seen any custom fields available from the v2 console

You could add them via POST request.

v3 doesn’t accept underscores in Attributes names either. So I’ve to change the names in any case. But it would be nice if I could export devices to json and edit the json afterwards to comply with the naming rules.

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [August 2, 2021, 3:40pm UTC](https://www.thethingsnetwork.org/forum/t/ttn-lw-migrate-fails-on-extra-fields/50292/6 "2021-08-02T15:40:31Z")

</div>

> [@wotan](#):
>
> doesn’t get triggered by dev\_id field name as dev\_id\_knd triggers the error.

Maybe they only validate the user fields.

> [@wotan](#):
>
> But it would be nice if I could export devices to json and edit the json afterwards to comply with the naming rules.

The output from the migration tool is JSON - so you can process / grep / sed it before importing in to v3.

---

<div class="post-metadata">

**Author:** ![wotan](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/wotan/32/36850_2.png) [@wotan](https://www.thethingsnetwork.org/forum/u/wotan)\
**Post date:** [August 2, 2021, 3:50pm UTC](https://www.thethingsnetwork.org/forum/t/ttn-lw-migrate-fails-on-extra-fields/50292/7 "2021-08-02T15:50:39Z")

</div>

> [@descartes](#):
>
> The output from the migration tool is JSON - so you can process / grep / sed it before importing in to v3.

Yes I know, but as I cannot export I cannot edit. Is there any example data available?

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [August 2, 2021, 4:19pm UTC](https://www.thethingsnetwork.org/forum/t/ttn-lw-migrate-fails-on-extra-fields/50292/8 "2021-08-02T16:19:16Z")

</div>

> [@wotan](#):
>
> Is there any example data available?

I thought I knew the v2 API but I wasn’t aware you could add attributes via the CLI. I do know the v3 API pretty well. I’ve not seen any examples with attributes out of v2 or in to v3 but I’ll gladly see what might be possible.

One other potential thing to try is to use the original v2 CLI to get the device info out and process it for import.

---

<div class="post-metadata">

**Author:** ![pwgebben](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/pwgebben/32/35697_2.png) [@pwgebben](https://www.thethingsnetwork.org/forum/u/pwgebben)\
**Post date:** [November 4, 2021, 8:52am UTC](https://www.thethingsnetwork.org/forum/t/ttn-lw-migrate-fails-on-extra-fields/50292/9 "2021-11-04T08:52:09Z")

</div>

I know this thread is a bit old, but I am currently facing the same problem when trying to export V2 devices to V3. Back in the days we used the V2 API to register devices and added custom attributes ‘deviceSN’, ‘registerDate’ and ‘registerFrom’, and the ttn-lw-migrate tool fails on these custom attributes since they do not match the regexp. Is there any way to skip this validation and let ttn-lw-migrate tool create a JSON file without these extra attributes, so that the devices can be imported in V3? Now it just fails and therefore does not produce any JSON…

Or do we need to craft the device JSON by hand in order to import the devices in V3?

---

<div class="post-metadata">

**Author:** ![wotan](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/wotan/32/36850_2.png) [@wotan](https://www.thethingsnetwork.org/forum/u/wotan)\
**Post date:** [November 17, 2021, 12:30pm UTC](https://www.thethingsnetwork.org/forum/t/ttn-lw-migrate-fails-on-extra-fields/50292/10 "2021-11-17T12:30:55Z")

</div>

Only two weeks left. I should hurry up now. [pwgebben](https://www.thethingsnetwork.org/forum/u/pwgebben) did you found a solution for our “extra field extra”?
