Skip to main content

Hello!
I'm getting this error when using .identify method from @amplitude/node

In fact, the user_id im using has less than 5 characters and I do understand that this is the HTTP v2 API rule.

But the point is, I have thousands of users in my project that have user_ids that are less than 5 characters long.. so now I will never be able to add properties to them from my nodejs app?

 

Same issue here just using the API, this is crazy behaviour!


Hi @rafael_correia & @nathan ,

 

Have you upgraded to the latest Node package from Amplitude? I would look up the npm package and make sure it is updated to the latest version.

 

Upon doing that and if the package is still returning an error, can you please show me the call you are making in the package as well as the Project ID and Org ID? Please make sure you remove any sensitive info. 

 

@nathan can you also show me this call on the API? Assuming you are using the HTTP API, there is an option were you can pass in to have the user_id limit to be reduced. 

 

I hope this helps for now! Looking forward to your response!

 

Kind Regards,

Denis


Hey @Denis Holmes here is the payload sent by Segment:

>
{
"body": "{
\"api_key\":\"**************\",
\"events\"::
{
\"os_name\":\"Chrome\",
\"os_version\":\"97\",
\"device_model\":\"Mac OS\",
\"event_properties\":{
\"endpoint_id\":\"web|landing|home\",
\"path\":\"/\",
\"referrer\":null,
\"route_id\":\"web|home\",
\"source\":\"website\",
\"url\":\"http://localhost:3000/\"
},
\"event_type\":\"Viewed \",
\"ip\":\"::1\",
\"use_batch_endpoint\":false,
\"user_id\":\"9\",
\"time\":1643715296127,
\"library\":\"segment\"
}
]
}",
"headers": {
"content-type": "application/json",
"user-agent": "Segment (Actions)"
},
"method": "POST",
"qs": {},
"url": "https://api2.amplitude.com/2/httpapi"
}
]

And here is the response:

>
{
"body": {
"code": 400,
"error": "Invalid id length for user_id or device_id",
"events_with_invalid_id_lengths": {
"user_id":
0
]
}
},
"headers": {
"access-control-allow-methods": "GET, POST",
"access-control-allow-origin": "*",
"connection": "close",
"content-length": "115",
"content-type": "application/json",
"date": "Tue, 01 Feb 2022 11:34:58 GMT",
"strict-transport-security": "max-age=15768000"
},
"statusCode": 400,
"statusMessage": "Bad Request"
}
]

 


 Hi @nathan ,

 

Do you have a User with the User ID of 9 in the system? It is a very short User ID and we don’t really recommend that approach. Device IDs and User IDs must be strings with a length of 5 characters or more. Here’s more information in our developer docs. This is to prevent potential instrumentation issues. While I am not too sure on Segments side, I think you should have the option to pass in options as a parameter and set the min_id_length. 
Can you check with Segment to see if they have the ability to pass such an option in the raw payload of the event? Thank you!

 


 


Hey @Denis Holmes thanks for your help!

So the approach you do not recommend is having database id sequences that start at 1 and have them start at 100000 instead? :wink:

That’s very much standard, with very few drawbacks if you do not need some sort of external anonymization for the ids.

It’s quite a weird default setting to have for Amplitude, and it would saner to make it configurable in the project options so that there is no need to specify it on every call.

I haven’t found a way yet to set it to min_id_length: 1 through segment yet, but I will contact them if I can’t figure it out.


Hey @nathan ,

 

Thanks for the reply! I think that would be better as it seems the shorter IDs do cause issues in our systems. It would be better to have one of 6 or more 😉 I did see some information from Segment here. I cannot say for sure if this is the same options but it might be and it might help! 

 

It’s quite a weird default setting to have for Amplitude, and it would saner to make it configurable in the project options so that there is no need to specify it on every call.

That’s a really nice and clean idea actually! I think they should know that. Can you do me one last favour and PM me the email you use with Amplitude? I can then submit this feedback on your behalf :)

 

Kind Regards,
Denis


@Denis Holmes  Ahhhh thanks a lot, I was using their new adapter “Amplitude Actions” and it’s missing the ability to add extra parameters on calls, but “Amplitude Classic” works fine!

Thanks again for your help, PMing you now.


Haha actually spoke too soon, this doesn’t seem to be doable even with the older Amplitude adapter.


Hmm, It is difficult to debug from my side if you are not using our HTTP API. What I would recommend is to now message Segment, show them our HTTP API option and ask them if they do have an option on their side to send that. If they do or do not, can you let me know their response? As I would be curious myself. Thank you! 


Yeah if you can’t disable this behaviour per account on your side it will have to come from Segment. Will let you know!


Any update on this one, guys? I can’t believe that Amplitude is rejecting our events because we use sequential user IDs...


HI @jordanful ,

 

Thanks for the comment! Would you be so kind as to make a new community post and describe the issue in as much details as possible with the Project and Org ID you have. One of my team members will then pick it up, thank you!


Thanks! No thanks though. We’ll just use mixpanel- they don’t have that silly constraint! 


Hi @jordanful I’m Jeremie the community manager. Sorry to hear that you’re having a tough time. We do our best to promote industry best practices and are here to help. Our team is also always open to feedback and continuously improving. Check out our product ideas forum where your input will be considered by the team. I’ve included more information below 😃 Thanks again for being a part of the Amplitude Community! 

 


Hello! 😁 I have some additional information and wanted to close the loop here. 

Here’s where you can find more information about min id length configuration in our developer center

The default setting is still to have user_id or device_id be >5 char length but in Segment there's an option to change that setting. Take a look: 

 


Hello! 😁 I have some additional information and wanted to close the loop here. 

Here’s where you can find more information about min id length configuration in our developer center

The default setting is still to have user_id or device_id be >5 char length but in Segment there's an option to change that setting. Take a look: 

 

For anyone looking to set this with the browser typescript SDK, it’s done on the init method:

amplitude.init(AMPLITUDE_API_KEY, USER_ID, { minIdLength: 1 })

 


Thank you @tweeres04 😀


@Denis Holmes You mentioned that “shorter IDs do cause issues in our systems”. What kind of issues? I am trying to determine whether to set minIdLength to 1 or not.

Our problem is that we have been using Amplitude on mobile for over 4 years and already have users in the system with ids less that 5 characters, eg: “510”. If we force them to be 5 characters, say by padding with 0s, eg: 00510, we will lose our historical tracking data for this particular user. One of the key metrics we tracking is user churn so the historical linkage is important.

Do you have any suggestions?

 


Hi @sophie Can you post this as a new community post so one of the team members can pick it up? Thank you!


Hi @Denis Holmes,Thanks for closing the loop here. I can create a ticket for @sophie. Can’t wait to get this resolved! 😀


Reply