Skip to content

Upgrading js-yaml 4 to 5

Breaking4.3.2 → 5.5.0Breaking16Security7Deprecated2New11Changed9Fixed20Other4

BreakingUpgrade verdict

16 breaking changes and 6 security fixes.

  • The `MERGE_KEY` export no longer exists.
  • The old maxMergeSeqLength setting is gone; use maxTotalMergeKeys instead.
  • The old safe* functions are gone; use load, loadAll and dump instead.
  • The DEFAULT_SCHEMA constant and the nested types export are no longer available.
Top 5 of 24 that need code or config changes

Moves argparse 2.0.1 → 3.0.4. Your build may pick other versions.

Breaking16
Removes the MERGE_KEY export.
MERGE_KEY
Removes the maxMergeSeqLength option, replaced by maxTotalMergeKeys for limiting YAML merge processing.
maxMergeSeqLengthmaxTotalMergeKeys
Removes deprecated safeLoad(), safeLoadAll() and safeDump() exports.
safeLoad()safeLoadAll()safeDump()
Removes DEFAULT_SCHEMA and the nested types export.
DEFAULT_SCHEMAtypes
Removes loader options onWarning, legacy and listener.
onWarninglegacylistener
Removes dumper options styles, replacer, noCompatMode, condenseFlow, quotingType and forceQuotes, and renames noArrayIndent to seqNoIndent.
stylesreplacernoCompatModecondenseFlowquotingTypeforceQuotesnoArrayIndentseqNoIndent
Flattens low-level AST node style representation: scalar and collection nodes use SCALAR_STYLE and COLLECTION_STYLE, explicit tags use tagged, alias nodes keep only kind and anchor.
SCALAR_STYLECOLLECTION_STYLEtaggedkindanchor
Rewrites the sortKeys option using AST mutation to avoid side effects.
sortKeys
Makes identify mandatory for custom tag definitions; use identify: () => false for load-only tags.
identify
quoteStyle now selects the preferred quote style; use the restored forceQuotes option to force quoting non-key strings.
quoteStyleforceQuotes
Rewrites the package in TypeScript and reorganizes the public API around flat named exports.
Reduces the set of exported schemas to CORE_SCHEMA, JSON_SCHEMA, FAILSAFE_SCHEMA and YAML11_SCHEMA.
CORE_SCHEMAJSON_SCHEMAFAILSAFE_SCHEMAYAML11_SCHEMA
Replaces the Type API with a tags API using defineScalarTag(), defineSequenceTag() and defineMappingTag().
TypedefineScalarTag()defineSequenceTag()defineMappingTag()
Renames Schema.extend() to Schema.withTags().
Schema.extend()Schema.withTags()
load() now throws on empty input instead of returning undefined.
load()
Removes support for importing internal files from lib/.
lib/
Security6
js-yaml: maxTotalMergeKeys does not limit CPU use for empty merge sources
maxTotalMergeKeysModerate · CVSS 5.3
Avoids exponential parsing time for nested flow sequence pairs.
js-yaml: Exponential parsing time in flow collections leads to denial of service
High · CVSS 7.5
Removes quadratic complexity from !!omap addItem, a regression from v5 that is usually not critical since YAML11_SCHEMA is no longer default.
!!omapaddItemYAML11_SCHEMA
js-yaml: Quadratic-complexity (O(n^2)) DoS via !!omap tag in YAML11_SCHEMA
Moderate · CVSS 5.3
js-yaml: YAML merge-key chains can force quadratic CPU consumption in js-yaml
Moderate · CVSS 5.3
Deprecated2
Deprecates flat constant exports in favor of grouped ones.
Deprecates the loadAll signature with an iterator, which still works but is a candidate for removal.
loadAll