Skip to content

Unrecognised and converted body to json #628

Description

@Jef-Z

Environment information

Version:

"dependencies": {
  "body-parser": "2.2.0",
  "express": "5.1.0",
}

Platform:

Linux: WSL: Linux 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Windows: Microsoft Windows NT 10.0.19045.0 x64

Node.js version:
v20.11.1

Any other relevant information:

const app: Express = express();

app.disable('x-powered-by');

// app.use(express.json());
app.use(bodyParser.json());

app.use('/webhook/after', (req, res) => {
  console.log('zjf---after-:', req.body);   // here!!!
  console.log('zjf---after-:', req.query);
  console.log('zjf---after-:', req.headers);
  console.log('zjf---after-:', req.method);

  try {
    if (Buffer.isBuffer(req.body)) {
      const jsonString = req.body.toString('utf-8');

      const data = JSON.parse(jsonString);

      console.log('zjf---after-req.body:', data);
    }
  } catch (error) {}

  res.status(200).send('OK');
});

Running in a container where the base image is almalinux.

Test it use Curl:

curl --location '${host}/webhook/after' \
--header 'content-type: application/json;charset=utf-8' \
--data '{
    "challenge": "ajls384kdjxxxx"
}'

Result:

Image

I am running locally and Docker is parsing it properly. I can't get you to reproduce our release environment and cloud function environment.
But please help to check what could be wrong.
thanks a lot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions