feat(deps): migrate to js-yaml v5#2197
Merged
Merged
Conversation
Bump js-yaml 4.2.0 -> 5.2.1 (a major version held back from the #2114 group bump). js-yaml v5 changed empty-input behavior: `load("")` now throws ("expected a document, but the input is empty") instead of returning `undefined`, which broke parsers relying on the old sentinel. Changes: - Bump js-yaml to 5.2.1 and drop @types/js-yaml (v5 ships its own types). - Add `loadYaml` (src/utils/yaml.ts): a thin wrapper that preserves v4's `undefined` return for empty/whitespace/comment-only documents (v5's YAMLException with reason "expected a document, but the input is empty") while re-throwing genuine parse errors. Single choke point so a future bump cannot reintroduce the empty-input regression. - Route every js-yaml `load` call through `loadYaml`. This fixes the two documented breakages (parseApmManifest, injectSourceMetadata) plus several undocumented ones that had the same "empty file parses to undefined/null" assumption in a try/catch (goose command/mcp/subagent, roo subagent). `dump` is unchanged (no removed options are used, and no default import / custom Type API exists in this codebase). No dump-format audit gaps: the Tool x Feature e2e matrix asserts on generated YAML byte-for-byte and stays green, confirming v5 `dump` output is compatible. Closes #2122 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
Author
|
@dyoshikawa Thank you! |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates
js-yamlfrom 4.2.0 to 5.2.1 (a major version that was held back from the #2114 dependabot group bump due to a breaking empty-input change).js-yaml v5 changed
load("")to throw (expected a document, but the input is empty) instead of returningundefined. Several parsers here relied on the oldundefinedsentinel, so a naive bump broke them.Approach
Centralized empty-input guard. Rather than patch each call site ad hoc, this adds
loadYaml(src/utils/yaml.ts) — a thin wrapper that:undefinedfor empty / whitespace-only / comment-only documents (matching v4), andYAMLException.reason === "expected a document, but the input is empty").Every js-yaml
loadcall now routes throughloadYaml, so the v4 contract lives in one place and a future bump cannot silently reintroduce the regression.Dependency changes:
js-yaml4.2.0 → 5.2.1@types/js-yaml— v5 is written in TypeScript and ships its own type declarations.Scope of breaking changes actually hit: the codebase already used named imports (
import { load, dump }), no default import, no customTypeAPI, and none of v5's removeddumpoptions (styles/replacer/noCompatMode/condenseFlow/quotingType/noArrayIndent) — onlylineWidth/noRefs/sortKeys, all retained. Sodumpneeded no changes.Bugs fixed
Beyond the two documented breakages:
parseApmManifest(apm-manifest.ts) — emptyapm.ymlnow returns{ dependencies: [] }instead of throwing.injectSourceMetadata(gh-frontmatter.ts) — empty frontmatter block (---\n---) is treated as an empty block, notinvalid frontmatter.…the migration also fixed several undocumented sites with the same "empty file parses to undefined/null" assumption inside a try/catch:
goose-command,goose-mcp,goose-subagent,roo-subagent(an empty file would have thrown a "Failed to parse …" error under a naive v5 bump).Verification
loadYamlunit tests cover empty / whitespace / comment-only / valid / invalid inputs.apm-manifest.test.ts,gh-frontmatter.test.ts) stay green.mcp,permissions,commands,subagents,skills): 437 pass — these assert on generated YAML byte-for-byte, empirically confirming v5dumpoutput is compatible across the Tool × Feature matrix.pnpm cicheckgreen.Closes #2122
🤖 Generated with Claude Code