Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 60 additions & 99 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"commander": "^12.0.0",
"ignore": "^5.3.0",
"minimatch": "^9.0.0",
"tar": "^6.2.0"
"tar": "^7.0.0"
},
"devDependencies": {
"@ai-sdk/anthropic": "^2.0.0",
Expand All @@ -80,7 +80,7 @@
"@octokit/rest": "^22.0.1",
"@types/express": "^5.0.6",
"@types/node": "^20.10.0",
"@types/tar": "^6.1.10",

"tsx": "^4.7.0",
"typescript": "^5.3.3",
"vitest": "^1.1.0"
Expand Down
7 changes: 4 additions & 3 deletions src/sources/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

import { Readable } from "node:stream";
import ignoreFactory, { type Ignore } from "ignore";
import tar from "tar";
import * as tar from "tar";
import type { ReadEntry } from "tar";
import { shouldFilterFile } from "../core/file-filter.js";
import { isoTimestamp } from "../core/utils.js";
import type { FileEntry, FileInfo, SourceMetadata } from "../core/types.js";
Expand Down Expand Up @@ -302,7 +303,7 @@ export class GitHubSource implements Source {

await new Promise<void>((resolve, reject) => {
const parser = tar.list({
onentry: (entry) => {
onReadEntry: (entry: ReadEntry) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

tar.list() (aka tar.t) is documented as listing-only; the ReadEntry objects it yields may not emit data/end events, but this code relies on those to capture file contents.
With the tar@7 bump, please double-check that onReadEntry here provides readable entry bodies (otherwise extracted files may be empty or the stream may never drain).

Other Locations
  • src/sources/gitlab.ts:260

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for flagging this! I investigated and addressed the concern:

Changes Made

  • Replaced tar.list() with tar.Parser in both github.ts and gitlab.ts
  • Updated onentryonReadEntry (deprecated in v7.4)
  • Added entry.resume() for skipped entries (directories/symlinks) to ensure the stream drains properly
  • Added proper TypeScript types (Parser, ReadEntry)

Testing

I ran integration tests with tar v7.5.7:

  1. tar.Parser approach ✅ Works correctly - data/end events fire and files have content
  2. tar.list() approach ✅ Also works in v7.5.7 (data events do fire)

Interestingly, tar.list() does emit data events in the current version, so the original code would have worked. However, the change to tar.Parser is still the right call because:

  • It's the semantically correct API for reading file contents (vs listing metadata)
  • It uses the non-deprecated onReadEntry callback
  • It's more explicit about intent

Build and all 162 tests pass. CI is green ✅

// Skip directories and symlinks
if (entry.type !== "File") {
return;
Expand All @@ -315,7 +316,7 @@ export class GitHubSource implements Source {

// Read file contents
const chunks: Buffer[] = [];
entry.on("data", (chunk) => chunks.push(chunk));
entry.on("data", (chunk: Buffer) => chunks.push(chunk));
entry.on("end", () => {
const contentBuffer = Buffer.concat(chunks);

Expand Down
7 changes: 4 additions & 3 deletions src/sources/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import { Readable } from "node:stream";
import ignoreFactory, { type Ignore } from "ignore";
import tar from "tar";
import * as tar from "tar";
import type { ReadEntry } from "tar";
import { shouldFilterFile } from "../core/file-filter.js";
import { isoTimestamp } from "../core/utils.js";
import type { FileEntry, FileInfo, SourceMetadata } from "../core/types.js";
Expand Down Expand Up @@ -256,7 +257,7 @@ export class GitLabSource implements Source {

await new Promise<void>((resolve, reject) => {
const parser = tar.list({
onentry: (entry) => {
onReadEntry: (entry: ReadEntry) => {
// Skip directories and symlinks
if (entry.type !== "File") {
return;
Expand All @@ -269,7 +270,7 @@ export class GitLabSource implements Source {

// Read file contents
const chunks: Buffer[] = [];
entry.on("data", (chunk) => chunks.push(chunk));
entry.on("data", (chunk: Buffer) => chunks.push(chunk));
entry.on("end", () => {
const contentBuffer = Buffer.concat(chunks);

Expand Down