Workflow AutomationOperationsn8nSchema

Why Long IDs Lose Their Last Digits in Automations

A record ID longer than 16 digits loses its last digits when any step parses it as a JavaScript number, because JavaScript numbers hold integers exactly only up to 9,007,199,254,740,991 (2 to the 53rd minus 1). The value is rounded to the nearest number JavaScript can store, so the result is a different, valid-looking ID that does not always end in zeros, and no step reports an error. The fix is to keep IDs as strings from the very first hop, because the damage usually happens at the trigger, before any step you can edit.

Alexey YushkinFounder, GENERAL INFORMATICS2 min read

Frequently Asked Questions

Because some step read the ID as a JavaScript number. JavaScript stores every number as a 64-bit float, which holds integers exactly only up to 9,007,199,254,740,991. A longer ID is rounded to the nearest value the float can hold, so 23843310506440191 becomes 23843310506440190, and nothing errors.

No. The value is rounded to the nearest representable number, which can be higher or lower than the original. An 18-digit ID of 120208542154140123 comes out as 120208542154140130, with the last two digits going up. Searching your data only for IDs ending in 00 will miss part of the damage.

Any integer ID with 17 or more digits, and 16-digit IDs above 9,007,199,254,740,991, when the source sends it as a bare JSON number or a destination stores it in a number field. Snowflake-style IDs from social and chat platforms, ad platform IDs and database bigint keys are the usual cases. An ID that arrives in quotes as a string is safe until a step converts it.

Not from the rounded value. Many different original IDs round to the same number, so the lost digits cannot be computed back. Re-fetch the record from the source system using another key, such as an email address, an order number or a timestamp, and store the correct ID as text.

Only if Python is the first thing that parses the payload. Python's json module keeps large integers exact. But in a platform built on Node.js, such as n8n, the trigger has already parsed the body before your Python code receives it, so the ID arrives pre-rounded.

SOURCES & CITATIONS

  1. Number.MAX_SAFE_INTEGER — MDN Web Docshttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
  2. X IDs — X Developer Platformhttps://docs.x.com/fundamentals/x-ids
  3. API Reference: Snowflakes — Discord Developer Docshttps://docs.discord.com/developers/reference
  4. Telegram Bot API — Telegramhttps://core.telegram.org/bots/api

About Alexey Yushkin

Alexey is the founder of GENERAL INFORMATICS LLC. He designs and ships AI and automation systems for businesses and operators across the US.

Connect on LinkedIn

Related reading

Want this kind of system in your business?

We build practical AI and automation systems for operators. Send us your current workflow and we will show you what to automate first.