From 974da05ceb163b456e9296e3e8b327655cb922f8 Mon Sep 17 00:00:00 2001 From: Bhavy Singhal Date: Sat, 30 May 2026 15:11:00 +0530 Subject: [PATCH] Improve history file format error message --- CHANGELOG.md | 7 +++++++ src/archivist/services/index.js | 3 +++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc6c0feb9..d39b987cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All changes that impact users of this module are documented in this file, in the [Common Changelog](https://common-changelog.org) format with some additional specifications defined in the CONTRIBUTING file. This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased [patch] + +> Development of this release was made on a volunteer basis by Bhavy Singhal. + +### Fixed +- Improve error message when history file is wrongly formatted as an object instead of an array + ## 12.0.2 - 2026-05-26 > Development of this release was supported by [User Rights](https://www.user-rights.org). diff --git a/src/archivist/services/index.js b/src/archivist/services/index.js index 980973379..2e7c8a229 100644 --- a/src/archivist/services/index.js +++ b/src/archivist/services/index.js @@ -260,6 +260,9 @@ async function loadServiceHistoryFiles(serviceId) { ]); Object.entries(serviceDeclaration.terms).forEach(([ termsType, declaration ]) => { + if (!Array.isArray(serviceHistory[termsType]) && serviceHistory[termsType] !== undefined) { + throw new Error(`History file for "${termsType}" is not properly formatted: expected an array but got an object. Please use [] instead of {}.`); + } serviceHistory[termsType] = serviceHistory[termsType] || []; serviceHistory[termsType].push(declaration); });