Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not possible to use multipart form data because of boundary #1140

Open
5 tasks done
jawadsef opened this issue Nov 28, 2023 · 0 comments
Open
5 tasks done

Not possible to use multipart form data because of boundary #1140

jawadsef opened this issue Nov 28, 2023 · 0 comments
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer

Comments

@jawadsef
Copy link

Software versions

Please provide at least OS and version of pact-js

  • OS: macOS Ventura Version 13.0.1 (22A400)
  • Consumer Pact library: e.g. Pact JS v2.6.0
"@pact-foundation/pact": "^12.1.0"
"@pact-foundation/pact-core": "^14.0.5"
  • Provider Pact library: not relevant, since this is just a consumer test
  • Node Version: v18.14.1

Issue Checklist

Please confirm the following:

  • I have upgraded to the latest
  • I have the read the FAQs in the Readme
  • I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures
  • I have set my log level to debug and attached a log file showing the complete request/response cycle
  • For bonus points and virtual high fives, I have created a reproducible git repository (see below) to illustrate the problem

Expected behavior

Test passes.

Actual behavior

Test fails.

Getting the following error:

Mock server failed with the following mismatches:
        0) The following request was incorrect: 
                POST /test            
                         1.0    $: Failed to parse the expected body as a MIME multipart body: 'no boundary in content-type'
                         1.1    $: Failed to parse the actual body as a MIME multipart body: 'no boundary in content-type'

I tried generating the boundary but didn't work either.

Steps to reproduce

Clone following repo: https://github.com/jawadsef/pact-js-repro-template (git clone git@github.com:jawadsef/pact-js-repro-template.git)

Run consumer test: https://github.com/jawadsef/pact-js-repro-template/blob/main/consumer.spec.ts (npm run test:consumer )

Relevant log files

[23:34:01.279] INFO (41652): 0.4.0: pact native library successfully found, and the correct version
2023-11-28T22:34:01.331419Z DEBUG ThreadId(01) pact_plugin_driver::catalogue_manager: Updated catalogue entries:
core/transport/http
core/transport/https
2023-11-28T22:34:01.333204Z DEBUG ThreadId(01) pact_plugin_driver::catalogue_manager: Updated catalogue entries:
core/content-generator/binary
core/content-generator/json
core/content-matcher/json
core/content-matcher/multipart-form-data
core/content-matcher/text
core/content-matcher/xml
2023-11-28T22:34:01.333600Z DEBUG ThreadId(01) pact_plugin_driver::catalogue_manager: Updated catalogue entries:
core/matcher/v1-equality
core/matcher/v2-max-type
core/matcher/v2-min-type
core/matcher/v2-minmax-type
core/matcher/v2-regex
core/matcher/v2-type
core/matcher/v3-content-type
core/matcher/v3-date
core/matcher/v3-datetime
core/matcher/v3-decimal-type
core/matcher/v3-includes
core/matcher/v3-integer-type
core/matcher/v3-null
core/matcher/v3-number-type
core/matcher/v3-time
core/matcher/v4-array-contains
core/matcher/v4-equals-ignore-order
core/matcher/v4-max-equals-ignore-order
core/matcher/v4-min-equals-ignore-order
core/matcher/v4-minmax-equals-ignore-order
core/matcher/v4-not-empty
(node:41652) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

 RUNS  ./consumer.spec.ts
2023-11-28T22:34:01.363863Z DEBUG tokio-runtime-worker hyper::proto::h1::io: parsed 9 headers
2023-11-28T22:34:01.363895Z DEBUG tokio-runtime-worker hyper::proto::h1::conn: incoming body is chunked encoding
2023-11-28T22:34:01.363970Z DEBUG tokio-runtime-worker hyper::proto::h1::decode: incoming chunked header: 0x63 (99 bytes)
2023-11-28T22:34:01.363996Z DEBUG tokio-runtime-worker pact_mock_server::hyper_server: Creating pact request from hyper request
2023-11-28T22:34:01.364011Z DEBUG tokio-runtime-worker pact_mock_server::hyper_server: Extracting query from uri /test
2023-11-28T22:34:01.364697Z DEBUG tokio-runtime-worker hyper::proto::h1::decode: incoming chunked header: 0x2A (42 bytes)
2023-11-28T22:34:01.364717Z DEBUG tokio-runtime-worker hyper::proto::h1::conn: incoming body completed
2023-11-28T22:34:01.365090Z  INFO tokio-runtime-worker pact_mock_server::hyper_server: Received request HTTP Request ( method: POST, path: /test, query: None, headers: Some({"connection": ["keep-alive"], "accept": ["*/*"], "sec-fetch-mode": ["cors"], "accept-language": ["*"], "user-agent": ["undici"], "content-type": ["multipart/form-data"], "accept-encoding": ["gzip", "deflate"], "host": ["127.0.0.1:63372"], "transfer-encoding": ["chunked"]}), body: Present(141 bytes, multipart/form-data) )
2023-11-28T22:34:01.366169Z  INFO tokio-runtime-worker pact_matching: comparing to expected HTTP Request ( method: POST, path: /test, query: None, headers: Some({"Content-Type": ["multipart/form-data"]}), body: Present(2 bytes) )
2023-11-28T22:34:01.366200Z DEBUG tokio-runtime-worker pact_matching:      body: '7B7D (2 bytes)'
2023-11-28T22:34:01.366205Z DEBUG tokio-runtime-worker pact_matching:      matching_rules: MatchingRules { rules: {PATH: MatchingRuleCategory { name: PATH, rules: {} }, HEADER: MatchingRuleCategory { name: HEADER, rules: {} }} }
2023-11-28T22:34:01.366222Z DEBUG tokio-runtime-worker pact_matching:      generators: Generators { categories: {} }
2023-11-28T22:34:01.366628Z DEBUG tokio-runtime-worker pact_matching::matchers: String -> String: comparing '/test' to '/test' ==> true cascaded=false matcher=Equality
2023-11-28T22:34:01.367642Z DEBUG tokio-runtime-worker pact_matching: expected content type = 'multipart/form-data', actual content type = 'multipart/form-data'
2023-11-28T22:34:01.367705Z DEBUG tokio-runtime-worker pact_matching: content type header matcher = 'RuleList { rules: [], rule_logic: And, cascaded: false }'
2023-11-28T22:34:01.368046Z DEBUG tokio-runtime-worker pact_plugin_driver::catalogue_manager: Looking for a content matcher for multipart/form-data
2023-11-28T22:34:01.369152Z DEBUG tokio-runtime-worker pact_matching: No content matcher defined for content type 'multipart/form-data', using core matcher implementation
2023-11-28T22:34:01.369193Z DEBUG tokio-runtime-worker pact_matching: Using body matcher for content type 'multipart/form-data'
2023-11-28T22:34:01.369210Z DEBUG tokio-runtime-worker pact_matching::binary_utils: matching MIME multipart contents
2023-11-28T22:34:01.370774Z DEBUG tokio-runtime-worker pact_matching: --> Mismatches: [BodyMismatch { path: "$", expected: Some(b"{}"), actual: Some(b"------formdata-undici-0.9267915492310101\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\nJohn Doe\r\n------formdata-undici-0.9267915492310101--"), mismatch: "Failed to parse the expected body as a MIME multipart body: 'no boundary in content-type'" }, BodyMismatch { path: "$", expected: Some(b"{}"), actual: Some(b"------formdata-undici-0.9267915492310101\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\nJohn Doe\r\n------formdata-undici-0.9267915492310101--"), mismatch: "Failed to parse the actual body as a MIME multipart body: 'no boundary in content-type'" }]
2023-11-28T22:34:01.371108Z DEBUG tokio-runtime-worker pact_mock_server::hyper_server: Request did not match: Request did not match - HTTP Request ( method: POST, path: /test, query: None, headers: Some({"Content-Type": ["multipart/form-data"]}), body: Present(2 bytes) )    0) $ -> Failed to parse the expected body as a MIME multipart body: 'no boundary in content-type'    1) $ -> Failed to parse the actual body as a MIME multipart body: 'no boundary in content-type'
2023-11-28T22:34:01.371252Z DEBUG tokio-runtime-worker hyper::proto::h1::io: flushed 1004 bytes
2023-11-28T22:34:01.382132Z DEBUG ThreadId(01) pact_matching::metrics: Could not get the tokio runtime, will not send metrics - there is no reactor running, must be called from the context of a Tokio 1.x runtime
2023-11-28T22:34:01.382168Z DEBUG ThreadId(01) pact_mock_server::server_manager: Shutting down mock server with ID 61f629a8-cbe4-49fc-817e-780a943c6b57 - MockServerMetrics { requests: 1 }
2023-11-28T22:34:01.382191Z DEBUG ThreadId(01) pact_mock_server::mock_server: Mock server 61f629a8-cbe4-49fc-817e-780a943c6b57 shutdown - MockServerMetrics { requests: 1 }
2023-11-28T22:34:01.382214Z DEBUG tokio-runtime-worker hyper::server::shutdown: signal received, starting graceful shutdown
[23:34:01.383] ERROR (41652): pact@12.1.0: Test failed for the following reasons:

  Mock server failed with the following mismatches:

        0) The following request was incorrect: 

                POST /test
            
                         1.0    $: Failed to parse the expected body as a MIME multipart body: 'no boundary in content-type'



                         1.1    $: Failed to parse the actual body as a MIME multipart body: 'no boundary in content-type'
@jawadsef jawadsef added bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer labels Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer
Projects
None yet
Development

No branches or pull requests

1 participant