Skip to content

parsePatch regex doesn't strip single-quoted YAML keys from pnpm-workspace.yaml diffs #691

Description

@ByronDWall

Problem

MATCH_PACKAGE_VERSION regex in src/parsePatch.ts (line ~9) uses "? to optionally strip double quotes around YAML keys, but pnpm's default output (and most YAML formatters) uses single quotes for scoped package names. This causes the captured package name to include the single quotes (e.g. '@commercetools/nimbus' instead of @commercetools/nimbus), producing a mangled lookup key that doesn't match the catalog map built by calculateCatalogUpdates.ts (which correctly parses YAML and produces clean keys).

Result

For any pnpm-workspace.yaml catalog entry with a single-quoted key (all scoped @org/pkg names by default), the action logs "No package.json files were updated" and writes no changeset, even though the catalog resolution and named-catalog support in calculateCatalogUpdates.ts works correctly.

Reproduction

Any monorepo using pnpm catalogs (named or default) with scoped packages. The diff line + '@commercetools/nimbus': 3.5.1 produces packageId = "'@commercetools/nimbus'@3.5.1" instead of "@commercetools/nimbus@3.5.1", so catalog[packageId] returns undefined.

Note

The action's own test fixtures in parsePatch.test.ts use double quotes for catalog entries, which is why the bug isn't caught by the existing test suite.

Suggested Fix

Change the regex from:

const MATCH_PACKAGE_VERSION = /^\+\s*"?([^\s]+?)"?:\s+"?([^\s]+?)"?$/u;

to:

const MATCH_PACKAGE_VERSION = /^\+\s*['"]?([^\s]+?)['"]?:\s+['"]?([^\s]+?)['"]?$/u;

Also add a test case with single-quoted scoped package names.

Version

v1.2.5 (SHA 874dac2372a085cb94f750e8bdf5b1173a838a75)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions