Skip to content

Commit 3ec5b48

Browse files
committed
lib: change ERR_INVALID_ARG_VALUE error message
Refs: nodejs#34682
1 parent b1831fe commit 3ec5b48

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+81
-81
lines changed

lib/internal/errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ E('ERR_INVALID_ARG_VALUE', (name, value, reason = 'is invalid') => {
10831083
inspected = `${inspected.slice(0, 128)}...`;
10841084
}
10851085
const type = name.includes('.') ? 'property' : 'argument';
1086-
return `The ${type} '${name}' ${reason}. Received ${inspected}`;
1086+
return `The '${name}' ${type} ${reason}. Received ${inspected}`;
10871087
}, TypeError, RangeError);
10881088
E('ERR_INVALID_ASYNC_ID', 'Invalid %s value: %s', RangeError);
10891089
E('ERR_INVALID_BUFFER_SIZE',

test/es-module/test-esm-dns-promises.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ assert.throws(() => {
1010
}, {
1111
code: 'ERR_INVALID_ARG_VALUE',
1212
name: 'TypeError',
13-
message: `The argument 'address' is invalid. Received '${invalidAddress}'`
13+
message: `The 'address' argument is invalid. Received '${invalidAddress}'`
1414
});

test/internet/test-dns-promises-resolve.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const dnsPromises = require('dns').promises;
1212
{
1313
code: 'ERR_INVALID_ARG_VALUE',
1414
name: 'TypeError',
15-
message: `The argument 'rrtype' is invalid. Received '${rrtype}'`
15+
message: `The 'rrtype' is invalid. Received '${rrtype}' argument`
1616
}
1717
);
1818
}

test/parallel/test-assert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ assert.throws(
10821082
assert.throws(
10831083
() => assert.throws(() => { throw new Error(); }, {}),
10841084
{
1085-
message: "The argument 'error' may not be an empty object. Received {}",
1085+
message: "The 'error' argument may not be an empty object. Received {}",
10861086
code: 'ERR_INVALID_ARG_VALUE'
10871087
}
10881088
);

test/parallel/test-buffer-no-negative-allocation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { SlowBuffer } = require('buffer');
77
const msg = {
88
code: 'ERR_INVALID_ARG_VALUE',
99
name: 'RangeError',
10-
message: /^The argument 'size' is invalid\. Received [^"]*$/
10+
message: /^The 'size' argument is invalid\. Received [^"]*$/
1111
};
1212

1313
// Test that negative Buffer length inputs throw errors.

test/parallel/test-buffer-over-max-length.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const kMaxLength = buffer.kMaxLength;
99
const bufferMaxSizeMsg = {
1010
code: 'ERR_INVALID_ARG_VALUE',
1111
name: 'RangeError',
12-
message: /^The argument 'size' is invalid\. Received [^"]*$/
12+
message: /^The 'size' argument is invalid\. Received [^"]*$/
1313
};
1414

1515
assert.throws(() => Buffer((-1 >>> 0) + 1), bufferMaxSizeMsg);

test/parallel/test-buffer-slow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ assert.throws(() => SlowBuffer(true), bufferInvalidTypeMsg);
5454
const bufferMaxSizeMsg = {
5555
code: 'ERR_INVALID_ARG_VALUE',
5656
name: 'RangeError',
57-
message: /^The argument 'size' is invalid\. Received [^"]*$/
57+
message: /^The 'size' argument is invalid\. Received [^"]*$/
5858
};
5959
assert.throws(() => SlowBuffer(NaN), bufferMaxSizeMsg);
6060
assert.throws(() => SlowBuffer(Infinity), bufferMaxSizeMsg);

test/parallel/test-buffer-tostring-rangeerror.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const len = 1422561062959;
1212
const message = {
1313
code: 'ERR_INVALID_ARG_VALUE',
1414
name: 'RangeError',
15-
message: /^The argument 'size' is invalid\. Received [^"]*$/
15+
message: /^The 'size' argument is invalid\. Received [^"]*$/
1616
};
1717
assert.throws(() => Buffer(len).toString('utf8'), message);
1818
assert.throws(() => SlowBuffer(len).toString('utf8'), message);

test/parallel/test-c-ares.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ dns.lookup('::1', common.mustCall((error, result, addressType) => {
7070
const err = {
7171
code: 'ERR_INVALID_ARG_VALUE',
7272
name: 'TypeError',
73-
message: `The argument 'rrtype' is invalid. Received '${val}'`,
73+
message: `The 'rrtype' argument is invalid. Received '${val}'`,
7474
};
7575

7676
assert.throws(

test/parallel/test-child-process-advanced-serialization.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if (process.argv[2] !== 'child') {
1111
child_process.spawn(process.execPath, [], { serialization: value });
1212
}, {
1313
code: 'ERR_INVALID_ARG_VALUE',
14-
message: "The property 'options.serialization' " +
14+
message: "The 'options.serialization' property " +
1515
"must be one of: undefined, 'json', 'advanced'. " +
1616
`Received ${inspect(value)}`
1717
});

test/parallel/test-console-tty-colors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ check(false, false, false);
6767
});
6868
},
6969
{
70-
message: `The argument 'colorMode' is invalid. Received ${received}`,
70+
message: `The 'colorMode' argument is invalid. Received ${received}`,
7171
code: 'ERR_INVALID_ARG_VALUE'
7272
}
7373
);

test/parallel/test-crypto-authenticated.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ for (const test of TEST_CASES) {
330330
}, {
331331
name: 'TypeError',
332332
code: 'ERR_INVALID_ARG_VALUE',
333-
message: "The property 'options.authTagLength' is invalid. " +
333+
message: "The 'options.authTagLength' property is invalid. " +
334334
`Received ${inspect(authTagLength)}`
335335
});
336336

@@ -344,7 +344,7 @@ for (const test of TEST_CASES) {
344344
}, {
345345
name: 'TypeError',
346346
code: 'ERR_INVALID_ARG_VALUE',
347-
message: "The property 'options.authTagLength' is invalid. " +
347+
message: "The 'options.authTagLength' property is invalid. " +
348348
`Received ${inspect(authTagLength)}`
349349
});
350350

@@ -354,7 +354,7 @@ for (const test of TEST_CASES) {
354354
}, {
355355
name: 'TypeError',
356356
code: 'ERR_INVALID_ARG_VALUE',
357-
message: "The property 'options.authTagLength' is invalid. " +
357+
message: "The 'options.authTagLength' property is invalid. " +
358358
`Received ${inspect(authTagLength)}`
359359
});
360360

@@ -363,7 +363,7 @@ for (const test of TEST_CASES) {
363363
}, {
364364
name: 'TypeError',
365365
code: 'ERR_INVALID_ARG_VALUE',
366-
message: "The property 'options.authTagLength' is invalid. " +
366+
message: "The 'options.authTagLength' property is invalid. " +
367367
`Received ${inspect(authTagLength)}`
368368
});
369369
}
@@ -454,7 +454,7 @@ for (const test of TEST_CASES) {
454454
}, {
455455
name: 'TypeError',
456456
code: 'ERR_INVALID_ARG_VALUE',
457-
message: "The property 'options.plaintextLength' is invalid. " +
457+
message: "The 'options.plaintextLength' property is invalid. " +
458458
`Received ${inspect(plaintextLength)}`
459459
});
460460
}

test/parallel/test-crypto-dh-stateless.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ const bobPublicKey = crypto.createPublicKey({
9292
assert.throws(() => crypto.diffieHellman({ privateKey: alicePrivateKey }), {
9393
name: 'TypeError',
9494
code: 'ERR_INVALID_ARG_VALUE',
95-
message: "The property 'options.publicKey' is invalid. Received undefined"
95+
message: "The 'options.publicKey' property is invalid. Received undefined"
9696
});
9797

9898
assert.throws(() => crypto.diffieHellman({ publicKey: alicePublicKey }), {
9999
name: 'TypeError',
100100
code: 'ERR_INVALID_ARG_VALUE',
101-
message: "The property 'options.privateKey' is invalid. Received undefined"
101+
message: "The 'options.privateKey' property is invalid. Received undefined"
102102
});
103103

104104
const privateKey = Buffer.from(

test/parallel/test-crypto-key-objects.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
4949
assert.throws(() => new KeyObject(TYPE), {
5050
name: 'TypeError',
5151
code: 'ERR_INVALID_ARG_VALUE',
52-
message: `The argument 'type' is invalid. Received '${TYPE}'`
52+
message: `The 'type' argument is invalid. Received '${TYPE}'`
5353
});
5454
}
5555

@@ -224,7 +224,7 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
224224
createPrivateKey({ key: Buffer.alloc(0), format: 'der', type: 'spki' });
225225
}, {
226226
code: 'ERR_INVALID_ARG_VALUE',
227-
message: "The property 'options.type' is invalid. Received 'spki'"
227+
message: "The 'options.type' property is invalid. Received 'spki'"
228228
});
229229

230230
// Unlike SPKI, PKCS#1 is a valid encoding for private keys (and public keys),
@@ -472,6 +472,6 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
472472
}, {
473473
name: 'TypeError',
474474
code: 'ERR_INVALID_ARG_VALUE',
475-
message: "The property 'options.cipher' is invalid. Received undefined"
475+
message: "The 'options.cipher' property is invalid. Received undefined"
476476
});
477477
}

test/parallel/test-crypto-keygen.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
559559
}), {
560560
name: 'TypeError',
561561
code: 'ERR_INVALID_ARG_VALUE',
562-
message: "The property 'options.paramEncoding' is invalid. " +
562+
message: "The 'options.paramEncoding' property is invalid. " +
563563
"Received 'otherEncoding'"
564564
});
565565
}
@@ -606,7 +606,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
606606
assert.throws(() => generateKeyPairSync('rsa2', {}), {
607607
name: 'TypeError',
608608
code: 'ERR_INVALID_ARG_VALUE',
609-
message: "The argument 'type' must be a supported key type. Received 'rsa2'"
609+
message: "The 'type' argument must be a supported key type. Received 'rsa2'"
610610
});
611611
}
612612

@@ -686,7 +686,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
686686
}), {
687687
name: 'TypeError',
688688
code: 'ERR_INVALID_ARG_VALUE',
689-
message: "The property 'options.publicKeyEncoding' is invalid. " +
689+
message: "The 'options.publicKeyEncoding' property is invalid. " +
690690
`Received ${inspect(enc)}`
691691
});
692692
}
@@ -706,7 +706,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
706706
}), {
707707
name: 'TypeError',
708708
code: 'ERR_INVALID_ARG_VALUE',
709-
message: "The property 'options.publicKeyEncoding.type' is invalid. " +
709+
message: "The 'options.publicKeyEncoding.type' property is invalid. " +
710710
`Received ${inspect(type)}`
711711
});
712712
}
@@ -726,7 +726,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
726726
}), {
727727
name: 'TypeError',
728728
code: 'ERR_INVALID_ARG_VALUE',
729-
message: "The property 'options.publicKeyEncoding.format' is invalid. " +
729+
message: "The 'options.publicKeyEncoding.format' property is invalid. " +
730730
`Received ${inspect(format)}`
731731
});
732732
}
@@ -743,7 +743,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
743743
}), {
744744
name: 'TypeError',
745745
code: 'ERR_INVALID_ARG_VALUE',
746-
message: "The property 'options.privateKeyEncoding' is invalid. " +
746+
message: "The 'options.privateKeyEncoding' property is invalid. " +
747747
`Received ${inspect(enc)}`
748748
});
749749
}
@@ -763,7 +763,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
763763
}), {
764764
name: 'TypeError',
765765
code: 'ERR_INVALID_ARG_VALUE',
766-
message: "The property 'options.privateKeyEncoding.type' is invalid. " +
766+
message: "The 'options.privateKeyEncoding.type' property is invalid. " +
767767
`Received ${inspect(type)}`
768768
});
769769
}
@@ -783,7 +783,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
783783
}), {
784784
name: 'TypeError',
785785
code: 'ERR_INVALID_ARG_VALUE',
786-
message: "The property 'options.privateKeyEncoding.format' is invalid. " +
786+
message: "The 'options.privateKeyEncoding.format' property is invalid. " +
787787
`Received ${inspect(format)}`
788788
});
789789
}
@@ -804,7 +804,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
804804
}), {
805805
name: 'TypeError',
806806
code: 'ERR_INVALID_ARG_VALUE',
807-
message: "The property 'options.privateKeyEncoding.cipher' is invalid. " +
807+
message: "The 'options.privateKeyEncoding.cipher' property is invalid. " +
808808
`Received ${inspect(cipher)}`
809809
});
810810
}
@@ -845,7 +845,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
845845
}), {
846846
name: 'TypeError',
847847
code: 'ERR_INVALID_ARG_VALUE',
848-
message: "The property 'options.privateKeyEncoding.passphrase' " +
848+
message: "The 'options.privateKeyEncoding.passphrase' property " +
849849
`is invalid. Received ${inspect(passphrase)}`
850850
});
851851
}
@@ -872,7 +872,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
872872
}), {
873873
name: 'TypeError',
874874
code: 'ERR_INVALID_ARG_VALUE',
875-
message: "The property 'options.modulusLength' is invalid. " +
875+
message: "The 'options.modulusLength' property is invalid. " +
876876
`Received ${inspect(modulusLength)}`
877877
});
878878
}
@@ -885,7 +885,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
885885
}), {
886886
name: 'TypeError',
887887
code: 'ERR_INVALID_ARG_VALUE',
888-
message: "The property 'options.publicExponent' is invalid. " +
888+
message: "The 'options.publicExponent' property is invalid. " +
889889
`Received ${inspect(publicExponent)}`
890890
});
891891
}
@@ -900,7 +900,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
900900
}), {
901901
name: 'TypeError',
902902
code: 'ERR_INVALID_ARG_VALUE',
903-
message: "The property 'options.modulusLength' is invalid. " +
903+
message: "The 'options.modulusLength' property is invalid. " +
904904
`Received ${inspect(modulusLength)}`
905905
});
906906
}
@@ -913,7 +913,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
913913
}), {
914914
name: 'TypeError',
915915
code: 'ERR_INVALID_ARG_VALUE',
916-
message: "The property 'options.divisorLength' is invalid. " +
916+
message: "The 'options.divisorLength' property is invalid. " +
917917
`Received ${inspect(divisorLength)}`
918918
});
919919
}
@@ -944,7 +944,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
944944
}, {
945945
name: 'TypeError',
946946
code: 'ERR_INVALID_ARG_VALUE',
947-
message: "The property 'options.namedCurve' is invalid. " +
947+
message: "The 'options.namedCurve' property is invalid. " +
948948
`Received ${inspect(namedCurve)}`
949949
});
950950
}
@@ -1066,7 +1066,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
10661066
}, {
10671067
name: 'TypeError',
10681068
code: 'ERR_INVALID_ARG_VALUE',
1069-
message: "The property 'options.publicKeyEncoding.type' is invalid. " +
1069+
message: "The 'options.publicKeyEncoding.type' property is invalid. " +
10701070
`Received ${inspect(type)}`
10711071
});
10721072
}
@@ -1081,7 +1081,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
10811081
}, {
10821082
name: 'TypeError',
10831083
code: 'ERR_INVALID_ARG_VALUE',
1084-
message: "The property 'options.hash' is invalid. " +
1084+
message: "The 'options.hash' property is invalid. " +
10851085
`Received ${inspect(hashValue)}`
10861086
});
10871087
}
@@ -1097,7 +1097,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
10971097
}, {
10981098
name: 'TypeError',
10991099
code: 'ERR_INVALID_ARG_VALUE',
1100-
message: "The property 'options.privateKeyEncoding.type' is invalid. " +
1100+
message: "The 'options.privateKeyEncoding.type' property is invalid. " +
11011101
`Received ${inspect(type)}`
11021102
});
11031103
}
@@ -1197,7 +1197,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
11971197
{
11981198
name: 'TypeError',
11991199
code: 'ERR_INVALID_ARG_VALUE',
1200-
message: "The property 'options.mgf1Hash' is invalid. " +
1200+
message: "The 'options.mgf1Hash' property is invalid. " +
12011201
`Received ${inspect(mgf1Hash)}`
12021202

12031203
}

test/parallel/test-crypto-sign-verify.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ assert.throws(
7676
{
7777
code: 'ERR_INVALID_ARG_VALUE',
7878
name: 'TypeError',
79-
message: "The property 'options.padding' is invalid. Received null",
79+
message: "The 'options.padding' property is invalid. Received null",
8080
});
8181

8282
assert.throws(
@@ -87,7 +87,7 @@ assert.throws(
8787
{
8888
code: 'ERR_INVALID_ARG_VALUE',
8989
name: 'TypeError',
90-
message: "The property 'options.saltLength' is invalid. Received null",
90+
message: "The 'options.saltLength' property is invalid. Received null",
9191
});
9292

9393
// Test signing and verifying

test/parallel/test-crypto.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ testImmutability(crypto.getCurves);
164164
const encodingError = {
165165
code: 'ERR_INVALID_ARG_VALUE',
166166
name: 'TypeError',
167-
message: "The argument 'encoding' is invalid for data of length 1." +
167+
message: "The 'encoding' argument is invalid for data of length 1." +
168168
" Received 'hex'",
169169
};
170170

test/parallel/test-dns-lookup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ assert.throws(() => {
5454
const err = {
5555
code: 'ERR_INVALID_ARG_VALUE',
5656
name: 'TypeError',
57-
message: "The argument 'hints' is invalid. Received 100"
57+
message: "The 'hints' argument is invalid. Received 100"
5858
};
5959
const options = {
6060
hints: 100,
@@ -72,7 +72,7 @@ assert.throws(() => {
7272
const err = {
7373
code: 'ERR_INVALID_ARG_VALUE',
7474
name: 'TypeError',
75-
message: "The argument 'family' must be one of: 0, 4, 6. Received 20"
75+
message: "The 'family' argument must be one of: 0, 4, 6. Received 20"
7676
};
7777
const options = {
7878
hints: 0,

0 commit comments

Comments
 (0)