Skip to content

node:http: missing argument/header/URL validation (assert.throws → Missing expected exception) #4907

Closed

Description

@proggeramlug

Summary

Node:http performs argument/header/URL validation that throws on bad input. Under Perry these validations are absent, so the test's assert.throws(...) fails with Missing expected exception (Perry accepts the bad input silently).

Validations missing

  • Header name/value: validateHeaderName / validateHeaderValue — invalid header field chars must throw ERR_INVALID_HTTP_TOKEN / ERR_INVALID_CHAR (test-http-invalidheaderfield.js, test-http-response-add-header-after-sent.js, test-http-response-remove-header-after-sent.js)
  • Request path/method: invalid path chars (test-http-invalid-path-chars.js), unescaped path (test-http-client-unescaped-path.js), invalid method (test-http-request-invalid-method-error.js)
  • Host header as array must throw (test-http-client-headers-host-array.js)
  • URLs: invalid URLs / non-http(s) protocol must throw (test-http-invalid-urls.js, test-http-url.parse-only-support-http-https-protocol.js)
  • insecureHTTPParser option validation (test-http-client-insecure-http-parser-error.js, test-http-insecure-parser-per-stream.js, test-https-insecure-parse-per-stream.js)
  • Content-Length mismatch detection (test-http-content-length-mismatch.js)
  • early hints invalid argument (test-http-early-hints-invalid-argument.js)

Failing tests (20)

test-http-client-headers-host-array.js          test-http-invalid-path-chars.js
test-http-client-insecure-http-parser-error.js   test-http-invalid-urls.js
test-http-client-invalid-path.js                 test-http-invalidheaderfield.js
test-http-client-timeout-option.js               test-http-request-invalid-method-error.js
test-http-client-unescaped-path.js               test-http-response-add-header-after-sent.js
test-http-content-length-mismatch.js             test-http-response-remove-header-after-sent.js
test-http-early-hints-invalid-argument.js        test-http-server-de-chunked-trailer.js
test-http-insecure-parser-per-stream.js          test-http-server.js
test-http-invalid-path-chars.js                  test-http-set-max-idle-http-parser.js
test-http-invalidheaderfield.js                  test-http-url.parse-only-support-http-https-protocol.js
test-https-insecure-parse-per-stream.js          test-https-simple.js

Acceptance

Bad header names/values, paths, methods, host-array, non-http protocols, and invalid options throw the matching ERR_* so the tests' assert.throws passes.


Part of #2132. Measured via scripts/node_core_subset.py --api http https vs pinned Node v22 corpus.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed defect or regressionparityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions