Skip to content

Bug: undefined in cliOverrides overrides default config values via object spread #13

@404-Page-Found

Description

@404-Page-Found

Description

In src/core/config.ts:51-55, the config merge uses object spread:

return {
    ...defaultConfig,
    ...fileConfig,
    ...cliOverrides,
}

When --stale-days is NOT provided, src/index.ts:49 passes staleDays: undefined in cliOverrides. JavaScript object spread treats an explicit undefined property as a real value, so { ...{ staleDays: 90 }, ...{ staleDays: undefined } } produces { staleDays: undefined }, destroying the default of 90.

Impact

Running git-broom clean without --stale-days causes staleDays to become undefined. This flows into getStaleBranches(undefined, cwd) which computes cutoff.setDate(cutoff.getDate() - NaN) producing an Invalid Date. All date comparisons against Invalid Date return false, so zero branches are ever classified as stale. The clean command silently does nothing for stale branches.

Suggested Fix

Filter out undefined values from cliOverrides before spreading, or use a deep merge utility that ignores undefined.

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