Skip to content

[BUG]: computeHealthScore & computeActivityClassification give wrong output for missing/null pushed_at #198

Description

@RounakKumarAgarwal

Bug Description

computeHealthScore() and computeActivityClassification() in src/services/analytics.js
parse repo.pushed_at with an unguarded new Date(repo.pushed_at). GitHub can return
pushed_at as null or omit it (e.g. a newly created or empty repository), and in those
cases both functions produce incorrect output with no error:

  • pushed_at missing (undefined) -> computeHealthScore returns NaN, which renders in the
    UI and corrupts any sorting/averaging that consumes the score.
  • pushed_at: null -> new Date(null) resolves to the Unix epoch (1970), so
    computeHealthScore returns a plausible-looking but wrong value and
    computeActivityClassification labels the repo "Hibernating" — a confidently incorrect
    classification for what may be a brand-new repo.

getTopRepositories() in the same file already guards this exact case:
Number.isFinite(pushedAtMs) ? ... : Infinity. The guard just wasn't applied to the two
functions above, so the codebase is internally inconsistent about handling the same field.

Steps to Reproduce

  1. Open src/services/analytics.js.
  2. Call the functions with a repo that has no valid pushed_at, e.g. in a node REPL:
import { computeHealthScore, computeActivityClassification } from './src/services/analytics.js'

computeHealthScore({ open_issues_count: 2 }, 1)                   // -> NaN
computeHealthScore({ pushed_at: null, open_issues_count: 0 }, 3)  // -> 39 (misleading)
computeActivityClassification({ pushed_at: null })               // -> "Hibernating" (wrong)
  1. Observe: no error is thrown; the NaN / epoch-derived values flow into the analytics model and the UI.

Logs and Screenshots

Reproduced locally on main (Node v22.17.0):

computeHealthScore({ pushed_at: null }):            39           (plausible but wrong)
computeActivityClassification({ pushed_at: null }): Hibernating  (wrong label)
computeHealthScore({ pushed_at: undefined }):       NaN

Environment Details

  • OS: Windows (MINGW64 / Git Bash)
  • Browser: Chrome
  • Node.js: 22.17.0
  • Branch: main
  • Affected functions: computeHealthScore, computeActivityClassification (src/services/analytics.js)
  • Existing tests in src/services/analytics.healthMetrics.test.js only feed valid dates,
    so this path is currently uncovered.

Impact

Medium - Feature works but has issues

Code of Conduct

  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions