5 min read
|
Saved February 14, 2026
|
Copied!
Do you care about this?
The article details a developer's experience with GitHub's API when trying to link PR comments to their database. It explains the differences between GitHub's node IDs and database IDs, revealing how to extract database IDs from node IDs using bitmasking and MessagePack decoding. The author also discusses the complexities of GitHub's dual ID formats and their implications.
If you do, here's more
The author faced a challenge while adding clickable links to GitHub pull request comments in Greptile, a code review tool. The problem arose from GitHub's two ID systems: the GraphQL API uses unique node IDs, while web URLs require database IDs. After realizing that the links generated from the node IDs didnโt work, the author investigated the relationship between the two ID formats. By decoding the node IDs and analyzing their structure, they discovered that the database ID is embedded within the lower 32 bits of the decoded node ID. This bitmask operation allowed them to extract the required database IDs without a costly migration.
Further exploration into GitHub's ID formats revealed a split between legacy and new systems. The legacy format involves a simple structure combining an object type and a database ID, while the new format uses MessagePack for binary serialization. The author identified that the new node IDs consist of an array where the second element is the repository's database ID, and the third is the object's database ID. This structure provides the context needed for global identification across GitHub. Ultimately, the author shared a way to convert node IDs into usable URLs for their application, turning a frustrating snag into a deeper understanding of GitHub's identification mechanics.
Questions about this article
No questions yet.