Skip to content

Node request info fills query_string from route params instead of the query string #204

Open

Description

@ejsmith

In @exceptionless/node 3.2.1, NodeRequestInfoPlugin builds @request.query_string from request.params (Express route parameters) instead of request.query. Events show route values as the query string, and the actual query string is never captured.

Where

What happens

For GET /users/42?search=abc&page=2 handled by app.get("/users/:id", ...), the event contains:

{ "path": "/users/42", "query_string": { "id": "42" } }

Expected

{ "path": "/users/42", "query_string": { "search": "abc", "page": "2" } }

Steps to reproduce

Express 5, @exceptionless/node 3.2.1:

import express from "express";
import { Exceptionless, KnownEventDataKeys } from "@exceptionless/node";

await Exceptionless.startup("API_KEY");
const app = express();
app.get("/users/:id", async (req, res) => {
  const ctx = await Exceptionless.createLog("demo").setContextProperty(KnownEventDataKeys.RequestInfo, req).submit();
  res.json(ctx.event.data["@request"]);
});
app.listen(3000);
// curl "http://localhost:3000/users/42?search=abc&page=2"

Suggested fix

Use request.query for query_string (add query: Record<string, unknown> to the request shape). Route params could be recorded separately if they are wanted, but they shouldn't go in query_string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions