Skip to content

Conversation

@deokjinkim
Copy link
Contributor

Third argument of ERR_INVALID_MIME_SYNTAX is invalid index (not string).

node/lib/internal/errors.js

Lines 1419 to 1422 in cde3296

E('ERR_INVALID_MIME_SYNTAX', (production, str, invalidIndex) => {
const msg = invalidIndex !== -1 ? ` at ${invalidIndex}` : '';
return `The MIME syntax for a ${production} in "${str}" is invalid` + msg;
}, TypeError);

When I tested with below example,

const { MIMEType } = require('node:util');
const myMIME = new MIMEType('text/javascript,');

Before

node:internal/mime:73
    throw new ERR_INVALID_MIME_SYNTAX('subtype', str, trimmedSubtype);
    ^

TypeError [ERR_INVALID_MIME_SYNTAX]: The MIME syntax for a subtype in "text/javascript," is invalid at javascript,
    at parseTypeAndSubtype (node:internal/mime:73:11)
    at new MIMEType (node:internal/mime:332:18)

After

node:internal/mime:73
    throw new ERR_INVALID_MIME_SYNTAX('subtype', str, invalidSubtypeIndex);
    ^

TypeError [ERR_INVALID_MIME_SYNTAX]: The MIME syntax for a subtype in "text/javascript," is invalid at 10
    at parseTypeAndSubtype (node:internal/mime:73:11)
    at new MIMEType (node:internal/mime:332:18)

Third argument of ERR_INVALID_MIME_SYNTAX is invalid index
(not string).
@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Nov 6, 2023
@deokjinkim deokjinkim marked this pull request as ready for review November 6, 2023 13:40
@deokjinkim deokjinkim requested a review from bmeck November 6, 2023 13:46
@deokjinkim deokjinkim added the review wanted PRs that need reviews. label Nov 10, 2023
@marco-ippolito
Copy link
Member

maybe we can improve the error message since The MIME syntax for a subtype in "text/javascript," is invalid at 10 is not very informative

@deokjinkim
Copy link
Contributor Author

Close this PR because duplicated to #49711.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants