Skip to content

feat(core): add Node ID universal decoder for offline database ID extraction#248

Merged
amondnet merged 5 commits into
mainfrom
244-add-node-id-universal-decoder-for-offline-database-id-extraction
Jan 15, 2026
Merged

feat(core): add Node ID universal decoder for offline database ID extraction#248
amondnet merged 5 commits into
mainfrom
244-add-node-id-universal-decoder-for-offline-database-id-extraction

Conversation

@amondnet

@amondnet amondnet commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Node ID를 API 호출 없이 로컬에서 디코딩하여 Database ID를 추출하는 유틸리티 함수 구현
  • NEW: Database ID → Node ID 인코딩 기능 추가 (encodeNodeId)
  • New 형식(MessagePack+Base64)과 Legacy 형식(텍스트 Base64) 모두 지원
  • 순수 JavaScript로 MessagePack 인코더/디코더 구현 (외부 의존성 없음)

Changes

  • src/lib/node-id-decoder.ts: Node ID 디코더/인코더 핵심 구현
    • decodeNodeId(): Node ID 전체 정보 디코딩
    • encodeNodeId(): Database ID → Node ID 인코딩 ✨ NEW
    • extractDatabaseId(): Database ID만 추출
    • isNewNodeId(), isLegacyNodeId(): 형식 감지
    • getNodeIdType(), getNodeIdPrefix(): 타입/프리픽스 추출
  • src/lib/id-converter.ts: 디코더/인코더 함수 통합 및 re-export
  • test/lib/node-id-decoder.test.ts: 38개 단위 테스트
  • test/lib/id-converter.test.ts: 통합 테스트 추가
  • docs-dev/GITHUB_ID_SYSTEMS.md: 오프라인 디코딩/인코딩 문서 추가

Test plan

  • bun test 전체 통과 (766 pass)
  • bun run lint:fix 통과
  • bun run type-check 통과
  • New 형식 Node ID 디코딩 테스트
  • Legacy 형식 Node ID 디코딩 테스트
  • Node ID 인코딩 테스트 (type/prefix 입력)
  • 라운드트립 테스트 (decode → encode → 원본과 일치)
  • 잘못된 입력에 대한 에러 처리 테스트

Usage Examples

Decoding (Node ID → Database ID)

import { decodeNodeId, extractDatabaseId } from 'gh-please/lib/id-converter'

decodeNodeId('PRRC_kwDOL4aMSs6Tkzl8')
// → { type: 'PullRequestReviewComment', databaseId: 2475899260, repositoryId: 797346890 }

extractDatabaseId('PRRC_kwDOL4aMSs6Tkzl8')
// → 2475899260

Encoding (Database ID → Node ID) ✨ NEW

import { encodeNodeId } from 'gh-please/lib/id-converter'

encodeNodeId({
  type: 'PullRequestReviewComment',
  repositoryId: 797346890,
  databaseId: 2475899260,
})
// → 'PRRC_kwDOL4aMSs6Tkzl8'

Reference

Closes #244

Add pure JavaScript implementation for decoding GitHub Node IDs
without API calls. Supports both New format (MessagePack+Base64)
and Legacy format (text Base64).

[Auto-checkpoint from /please:dev Phase 6]

Tasks: T001, T002
Files: 2 files added
Issue: #244
- Re-export decoder functions from id-converter.ts
- Enhance isNodeId() to detect both New and Legacy formats
- Add integration tests for re-exported functions

[Auto-checkpoint from /please:dev Phase 6]

Tasks: T003, T004
Files: 2 files modified
Issue: #244
- Add Node ID Formats section (New format: MessagePack+Base64, Legacy format: text Base64)
- Add Offline Node ID Decoding section with usage examples
- Document decodeNodeId() and extractDatabaseId() functions
- Reference Greptile blog for original research

Task: T005
Issue: #244
@amondnet amondnet linked an issue Jan 15, 2026 that may be closed by this pull request
10 tasks
@vercel

vercel Bot commented Jan 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
gh-please Ready Ready Preview, Comment Jan 15, 2026 2:59pm

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @amondnet, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement by providing a robust, offline utility for decoding GitHub Node IDs and extracting their corresponding Database IDs. This functionality eliminates the need for API calls, offering instant and reliable ID conversion for both modern MessagePack-based Node IDs and older text-based legacy formats. The change improves the tool's independence and performance by enabling local processing of these identifiers.

Highlights

  • Universal Node ID Decoder: Implemented a universal Node ID decoder that can extract Database IDs locally without requiring API calls, enhancing offline capabilities.
  • Dual Format Support: The decoder supports both the new GitHub Node ID format (MessagePack + Base64) and the legacy format (text Base64).
  • Pure JavaScript MessagePack Decoder: A custom, minimal MessagePack decoder was developed in pure JavaScript, avoiding external dependencies for this core functionality.
  • Comprehensive Utility Functions: New utility functions were added for Node ID detection (isNewNodeId, isLegacyNodeId), prefix/type extraction (getNodeIdPrefix, getNodeIdType), and full decoding (decodeNodeId, extractDatabaseId).
  • Extensive Testing and Documentation: Comprehensive unit and integration tests were added, and detailed documentation for offline Node ID decoding was included in docs-dev/GITHUB_ID_SYSTEMS.md.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov

codecov Bot commented Jan 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.89655% with 38 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/lib/node-id-decoder.ts 86.66% 38 Missing ⚠️

📢 Thoughts on this report? Let us know!

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이 PR은 API 호출 없이 GitHub Node ID를 로컬에서 디코딩하는 유용한 유틸리티를 추가합니다. 새로운 형식(MessagePack)과 레거시 형식을 모두 지원하며, 외부 의존성 없이 순수 TypeScript로 MessagePack 디코더를 구현한 점이 인상적입니다. 전체적인 코드 품질이 매우 높고, 테스트 커버리지도 훌륭합니다. 코드 중복을 줄이기 위한 작은 리팩토링 제안을 하나 드립니다. 훌륭한 기여에 감사드립니다!

Comment thread src/lib/node-id-decoder.ts Outdated
- Add encodeNodeId() function for offline Node ID encoding
- Support both type name and prefix input formats
- Implement MessagePack array encoder (fixarray, fixint, uint8/16/32)
- Add URL-safe Base64 encoding (without padding)
- Roundtrip safe: decode(encode(x)) === x
- Add 15 new test cases for encoding functionality
- Update documentation with encoding examples

Issue: #244
Extract common Base64 preparation logic (URL-safe character conversion
and padding) into a dedicated prepareBase64() helper function.

This reduces code duplication between decodeBase64ToBytes() and
decodeBase64ToString() functions.

Suggested-by: gemini-code-assist[bot]
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@amondnet
amondnet merged commit 4eed388 into main Jan 15, 2026
7 of 8 checks passed
@amondnet
amondnet deleted the 244-add-node-id-universal-decoder-for-offline-database-id-extraction branch January 15, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add Node ID universal decoder for offline Database ID extraction

1 participant