From 8dc02218db37a2e3f5a02a500cf1b3c44c3cfaaa Mon Sep 17 00:00:00 2001 From: Chris Yau Date: Fri, 29 May 2026 11:10:34 +0800 Subject: [PATCH] fix: null-safe package.json access in getRepoChecks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review follow-up (CodeRabbit + cubic): switching to safeParseJson at line 389 means packageJson can be null on a missing/malformed package.json, but the quality-ci-validations check dereferenced packageJson.scripts before the optional chaining could help — throwing TypeError instead of degrading. Guard the base object with packageJson?.scripts?.test at the access site, matching the file's existing convention (e.g. line 220 uses packageJson?.name). Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- scripts/harness-audit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/harness-audit.js b/scripts/harness-audit.js index a7caa397..16edf248 100644 --- a/scripts/harness-audit.js +++ b/scripts/harness-audit.js @@ -312,7 +312,7 @@ function getRepoChecks(rootDir) { scopes: ['repo'], path: 'package.json', description: 'Test script runs validator chain before tests', - pass: typeof packageJson.scripts?.test === 'string' && packageJson.scripts.test.includes('validate-commands.js') && packageJson.scripts.test.includes('tests/run-all.js'), + pass: typeof packageJson?.scripts?.test === 'string' && packageJson?.scripts?.test.includes('validate-commands.js') && packageJson?.scripts?.test.includes('tests/run-all.js'), fix: 'Update package.json test script to run validators plus tests/run-all.js.', }, {