Skip to content

Fix blank pnpm current versions in Library Tracking uploads (LIBTRACK-136)#35

Merged
naarok merged 3 commits into
masterfrom
libtrack-136-version-number-not-populated-for-frontend
Jun 9, 2026
Merged

Fix blank pnpm current versions in Library Tracking uploads (LIBTRACK-136)#35
naarok merged 3 commits into
masterfrom
libtrack-136-version-number-not-populated-for-frontend

Conversation

@naarok

@naarok naarok commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Why

For pnpm repos (e.g. jobber-frontend), the analyzer uploaded a blank current_version for ~every library, so Library Tracking showed no installed version (LIBTRACK-136).

Root cause (confirmed from the nightly static_analysis upload log — every library uploaded as name @ <blank>): Pnpm#add_all_libraries parsed the rendered text of pnpm list --depth=0 --silent with two regexes that both begin with ^.*?\s, i.e. they require a leading tree prefix (├── ) before the package name. In the non-TTY CI environment pnpm emits bare name@version lines with no prefix, so both regexes match nothing.

A second defect in the same path: pnpm list --dir <subdir> resolves to the workspace root, so all 24 workspaces were analyzed against identical root data (per-workspace analysis wasn't actually per-workspace).

What changed

  • Resolve current versions from the structured pnpm list --depth=0 --json output (reading the version field) instead of scraping rendered tree text — eliminates the TTY/format dependence.
  • Select the JSON array entry by the analyzed workspace's absolute path, instead of relying on --dir — fixes the per-workspace duplication.
  • Preserve existing behavior: libyear merge, the a..b multi-version range (calculate_version), and empty handling for link:/workspace: specifiers.
  • Add a #add_all_libraries spec (the method was stubbed everywhere previously).

Verification

Ran the new add_all_libraries against live pnpm list --json from the jobber-frontend worktree:

workspace libs blank versions wrangler storybook
root 36 0 3.114.1 – (not a root dep)
apps/jobber-online 119 0 3.114.1 9.0.16
packages/core 12 0

Per-workspace key sets now differ (119 vs 12) — the duplicate-root-data bug is fixed. Result is rendering-independent, so CI matches local.

⚠️ The full bundle exec rspec suite could not be run in the worktree due to a pre-existing multi_json/google-apis lockfile gap (spec_helper loads the whole library, which pulls google/apis/sheets_v4) — unrelated to this change. The new logic was verified end-to-end against the real pnpm.rb via an isolated harness reproducing every spec scenario.

Follow-ups (not in this PR)

  • Cut a release/tag and bump jobber-frontend bin/Gemfile to consume the fix.
  • jobber-frontend's scripts/codeAnalysis/.../libraryVersionAnalysis.ts greedily JSON.parse-ing the gem stdout (fails on Ruby hash-inspect output) — separate jobber-frontend-owned change.
  • No data backfill required: displayed versions self-heal on the next good nightly (newest version record wins) and orphan rows age out of the UI after the 5-day recently_seen threshold.

OpenSpec change: openspec/changes/fix-pnpm-current-version-resolution.

Co-Authored-By: Amplify 2.1.1 amplify@getjobber.com

🤖 Generated with Claude Code

naarok and others added 3 commits June 9, 2026 13:54
…-136)

Resolve each dependency's current version from the structured
`pnpm list --depth=0 --json` output instead of scraping the rendered tree
text. The previous regexes both began with `^.*?\s`, requiring a leading
`├── ` prefix that pnpm omits in non-TTY/CI runs, so current_version came
back blank for ~every library and was uploaded that way.

Also select the JSON entry by the analyzed workspace path instead of
`pnpm list --dir <subdir>`, which collapsed to the repo root and made every
workspace's analysis identical.

Preserves the libyear merge, the a..b multi-version range, and empty
handling for link:/workspace: specifiers. Adds an #add_all_libraries spec
(previously stubbed). Includes the OpenSpec change artifacts under
openspec/changes/fix-pnpm-current-version-resolution.

Co-Authored-By: Amplify 2.1.1 <amplify@getjobber.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
representable (pulled in via google-api-client) requires "multi_json" at
runtime but does not declare it as a dependency, so bundler omitted it and
`require "google/apis/sheets_v4"` failed with "multi_json is not part of the
bundle", aborting spec_helper load. Add multi_json to the Gemfile.

`bundle exec rspec` now passes (116 examples, 0 failures), including the new
#add_all_libraries specs. (Gemfile.lock is gitignored for this gem; CI
regenerates it from the Gemfile.)

Co-Authored-By: Amplify 2.1.1 <amplify@getjobber.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move the completed OpenSpec change to the archive and promote its delta
into a living spec at openspec/specs/pnpm-version-analysis/spec.md
(3 requirements). The deferred release task (5.1) remains as a follow-up.

Co-Authored-By: Amplify 2.1.1 <amplify@getjobber.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@naarok naarok merged commit 6e48462 into master Jun 9, 2026
1 check passed
@naarok naarok deleted the libtrack-136-version-number-not-populated-for-frontend branch June 9, 2026 20:16
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.

1 participant