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

[V3] body is modified to JSON object even for non-JSON data (regression in 10.0.0-beta.60) #884

Open
4 of 5 tasks
individual-it opened this issue Jul 5, 2022 · 7 comments
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer

Comments

@individual-it
Copy link
Contributor

Software versions

Please provide at least OS and version of pact-js

  • OS: Ubuntu 21.10
  • Consumer Pact library: Pact JS v10.0.0-beta.60
  • Provider Pact library: Pact JS v10.0.0-beta.60
  • Node Version: 16.0.0

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 reproduceable git repository (see below) to illustrate the problem

Expected behaviour

when using Content-Type: application/x-www-form-urlencoded the data in the body would be send as it is

Actual behaviour

data is encoded into a JSON object
an interaction like

"description": "as 'admin', a POST request to create a user",
"request": {
  "body": "password=1234&userid=testUser1",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded",
    "authorization": "Basic YWRtaW46YWRtaW4="
  },
.....

results in this request to the provider
image

Steps to reproduce

  1. create an interaction with "Content-Type": "application/x-www-form-urlencoded"
  2. set a body
  3. run provider tests
  4. observe what is send to the provider

reproducible example: https://github.com/pact-foundation/pact-js/pull/883/files
the test 'creates a new mate with application/x-www-form-urlencoded data' works with 10.0.0-beta.59 but fails with 10.0.0-beta.60 because the data is not urlencoded but wrapped into a JSON object

@individual-it individual-it added the bug Indicates an unexpected problem or unintended behavior label Jul 5, 2022
@mefellows
Copy link
Member

It seems like this is working now @individual-it - are you able to confirm? The tests with that PR are definitely green, and it looks like the body is correct.

@YOU54F
Copy link
Member

YOU54F commented Aug 25, 2022

So it looks like the test was failing, but enablingPending:true is set, so the build doesn't fail, where there are provider verification failures.

This is a build from master showing the failing verification from a build log

https://github.com/pact-foundation/pact-js/runs/8017993797?check_suite_focus=true#step:4:6991

This is a comment and hack in to make the verification pass, and way to repro the issue

https://github.com/pact-foundation/pact-js/blob/e2e_example_matchers/examples/v3/e2e/provider.js#L100

here is the passing test, with the above code in

https://github.com/pact-foundation/pact-js/runs/8024802481?check_suite_focus=true#step:4:9656

@individual-it
Copy link
Contributor Author

@mefellows sorry for the late reply I have been pretty busy last month
the issue seems to persist in 10.1.2
if it help you, here is the interaction that is created by the test I've posted in #883

    {
      "description": "a request to create a new mate with x-www-form-urlencoded data",
      "providerStates": [
        {
          "name": "is authenticated"
        }
      ],
      "request": {
        "body": "first_name=Nanny&last_name=Doe",
        "headers": {
          "Content-Type": "application/x-www-form-urlencoded"
        },
        "method": "POST",
        "path": "/animals"
      },
      "response": {
        "body": {
          "first_name": "Nanny",
          "id": 1,
          "last_name": "Doe"
        },
        "headers": {
          "Content-Type": "application/json; charset=utf-8"
        },
        "matchingRules": {
          "body": {
            "$": {
              "combine": "AND",
              "matchers": [
                {
                  "match": "type"
                }
              ]
            }
          },
          "header": {}
        },
        "status": 200
      }
    }

@jomarocas
Copy link

this bug is still persist in version of pack-js 10.4.0

@github-actions
Copy link

github-actions bot commented Mar 3, 2023

👋 Hi! The 'smartbear-supported' label has just been added to this issue, which will create an internal tracking ticket in PactFlow's Jira (PACT-786). We will use this to prioritise and assign a team member to this task. All activity will be public on this ticket. For now, sit tight and we'll update this ticket once we have more information on the next steps.

See our documentation for more information.

@diestrin
Copy link

diestrin commented Sep 20, 2023

I can confirm this is still happening on @pact-foundation/pact@12.1.0

@mefellows mefellows added the triage This issue is yet to be triaged by a maintainer label Sep 20, 2023
@mefellows
Copy link
Member

Thanks for confirming. We still need to investigate if the issue is in Pact JS or in the upstream FFI - any help on that would be welcome to help us progress this.

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
Status: New Issue
Development

No branches or pull requests

5 participants