Commit 8592b1c8f34 for nodejs
commit 8592b1c8f3409c4cd7923d96b2d4f2f376a1e5e0
Author: Ved Chaudhari <84765263+vedchaudhari@users.noreply.github.com>
Date: Fri Nov 27 00:46:31 2026 +0530
permission: suggest --allow-fs-write in writeReport errors
process.report.writeReport() checks the fs.write permission in JS
and threw ERR_ACCESS_DENIED without the "Use --allow-fs-write to
manage permissions." hint that the other permission errors have.
Add it.
Refs: https://github.com/nodejs/node/pull/66969
Signed-off-by: vedchaudhari <vedc2853@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67681
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
diff --git a/lib/internal/process/report.js b/lib/internal/process/report.js
index c383dc8caeb..c946915afa5 100644
--- a/lib/internal/process/report.js
+++ b/lib/internal/process/report.js
@@ -40,7 +40,7 @@ const report = {
}
if (!permission.has('fs.write', resource)) {
throw new ERR_ACCESS_DENIED(
- 'Access to this API has been restricted',
+ 'Access to this API has been restricted. Use --allow-fs-write to manage permissions.',
'FileSystemWrite',
resource,
);
diff --git a/test/parallel/test-permission-fs-write-report.js b/test/parallel/test-permission-fs-write-report.js
index 7a726ce8e50..33253fd91e9 100644
--- a/test/parallel/test-permission-fs-write-report.js
+++ b/test/parallel/test-permission-fs-write-report.js
@@ -33,6 +33,7 @@ tmpdir.refresh();
assert.throws(() => {
process.report.writeReport('./secret.txt');
}, common.expectsError({
+ message: 'Access to this API has been restricted. Use --allow-fs-write to manage permissions.',
code: 'ERR_ACCESS_DENIED',
permission: 'FileSystemWrite',
resource: './secret.txt',
@@ -43,6 +44,7 @@ tmpdir.refresh();
assert.throws(() => {
process.report.writeReport();
}, common.expectsError({
+ message: 'Access to this API has been restricted. Use --allow-fs-write to manage permissions.',
code: 'ERR_ACCESS_DENIED',
permission: 'FileSystemWrite',
resource: process.cwd(),
@@ -96,6 +98,7 @@ spawnSyncAndExitWithoutError(
assert.throws(() => {
process.report.writeReport('report.json');
}, {
+ message: 'Access to this API has been restricted. Use --allow-fs-write to manage permissions.',
code: 'ERR_ACCESS_DENIED',
permission: 'FileSystemWrite',
resource: ${JSON.stringify(deniedFile)},
@@ -128,6 +131,7 @@ spawnSyncAndExitWithoutError(
assert.throws(() => {
process.report.writeReport();
}, {
+ message: 'Access to this API has been restricted. Use --allow-fs-write to manage permissions.',
code: 'ERR_ACCESS_DENIED',
permission: 'FileSystemWrite',
resource: ${JSON.stringify(deniedFile)},