Skip to content

Bug: byType object produces NaN for unexpected git object types #16

@404-Page-Found

Description

@404-Page-Found

Description

In src/commands/objects.ts:21-22:

const byType = { commit: 0, tree: 0, blob: 0 }
for (const obj of objects) byType[obj.type]++

The byType object only has keys for commit, tree, and blob. However, git fsck --unreachable can also report other types such as tag. If obj.type is 'tag', then byType['tag'] is undefined, and undefined++ evaluates to NaN.

Impact

The type summary table (lines 24-30) would display NaN for any unrecognized type. Additionally, the type assertion in git.ts:116 blindly casts whatever string git fsck outputs without validating it against the union 'commit' | 'tree' | 'blob', allowing invalid types to propagate through.

Suggested Fix

Initialize counts dynamically or add a default case, and validate object types in git.ts against the expected union.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions