Single item array query parameter not correctly parsed in Azure App Services in 5.2.1 #7179
-
|
When we deploy our app on Azure App Services, a single query parameter is not parsed when using the Environment informationVersion: 5.2.1 Platform: Linux Azure App Services Node.js version: 24 Any other relevant information: Issue only occurs when running on Azure App Services. When running locally, it works as expected This issue started for us after upgrading to the 5.2.1 version. We had no issues when running the 4.18.x version What steps will reproduce the bug?Add a debug endpoint, e.g.; router.get("/debug/query", (req: Request, res: Response) => {
const rawQueryString = req.originalUrl.split("?")[1] ?? "";
return res.json({
parsedQuery: req.query,
rawQuery: {
queryString: rawQueryString,
},
});
});Send a request with the query format |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
What is your I don't know what is going on with your Azure App Services and local version, but what you have described is one of the differences between simple and extended parsers. For example: const express = require("express");
const expressVersion = require("express/package.json").version;
const qsVersion = require("qs/package.json").version;
const nodeVersion = require("node:process").version;
/** @param {("simple" | "extended")?} parser */
function testParser(parser) {
return new Promise((resolve) => {
const app = express();
if (parser) {
app.set("query parser", parser);
}
app.get("/", (req, res) => {
res.json({ query: req.query });
});
const server = app.listen(0, "127.0.0.1", async () => {
const { port } = server.address();
const query = "param[]=value";
const parsed = await fetch(`http://127.0.0.1:${port}/?${query}`).then(r => r.json());
const parserDetails = app.get("query parser") === "extended" ? `"extended" (qs ${qsVersion})` : `"simple" (node:querystring ${nodeVersion})`;
const parserInfo = parser ? parserDetails : `default (${parserDetails})`;
console.log(`Express ${expressVersion}, parser ${parserInfo}: /?${query} =>`, parsed);
resolve();
server.close();
});
});
}
(async () => {
await testParser();
await testParser("simple");
await testParser("extended");
})();$ npm install --silent express@4 && node index.js
Express 4.22.1, parser default ("extended" (qs 6.14.2)): /?param[]=value => { query: { param: [ 'value' ] } }
Express 4.22.1, parser "simple" (node:querystring v25.8.2): /?param[]=value => { query: { 'param[]': 'value' } }
Express 4.22.1, parser "extended" (qs 6.14.2): /?param[]=value => { query: { param: [ 'value' ] } }
$ npm install --silent express@5 && node index.js
Express 5.2.1, parser default ("simple" (node:querystring v25.8.2)): /?param[]=value => { query: { 'param[]': 'value' } }
Express 5.2.1, parser "simple" (node:querystring v25.8.2): /?param[]=value => { query: { 'param[]': 'value' } }
Express 5.2.1, parser "extended" (qs 6.14.2): /?param[]=value => { query: { param: [ 'value' ] } } |
Beta Was this translation helpful? Give feedback.
-
|
Switching to extended indeed fixes the issue. I can't reproduce the issue we had at the moment and currently i see the same behaviour in our local and azure environment. It seems like our local environment is a bit unstable. Thanks for the help, I'll close this discussion and issue! |
Beta Was this translation helpful? Give feedback.
What is your
"query parser"setting? Express 5 changed the default from"extended"(which usesqs) to"simple"(node:querystring).I don't know what is going on with your Azure App Services and local version, but what you have described is one of the differences between simple and extended parsers. For example: