Home / Companies / Greptile / Blog / Post Details
Content Deep Dive

Every GitHub Object Has Two IDs | Greptile Blog

Blog post from Greptile

Post Details
Company
Date Published
Author
-
Word Count
1,278
Language
English
Hacker News Points
-
Summary

While developing a feature for Greptile, an AI-powered code review tool, the author encountered an issue with GitHub's API related to generating clickable links in GitHub PR comments. This problem arose from GitHub's use of two distinct ID systems: node IDs from the GraphQL API and database IDs visible in URLs. The author discovered that node IDs are base64 encoded, and through analysis, identified that the database ID is embedded in the last 32 bits of the decoded node ID. This insight allowed them to bypass a potential database migration by using a simple bitmask operation to extract the necessary database ID. Further exploration revealed that GitHub's node IDs employ a MessagePack encoding format, integrating various identifiers such as a repository's database ID and specific object identifiers, which explained the complexity and redundancy in GitHub's ID systems. This deep dive into GitHub's ID structure not only solved the immediate problem but also revealed the intricate mechanics behind GitHub's ID generation and management.