Skip to content

feat: Impossible to use UUID as param for object construction #703

Closed
@ivanproskuryakov

Description

@ivanproskuryakov

Description

The usage of UUID instead of id in routes like: http://0.0.0.0:3000/api/products/04879b32-c329-48d7-a652-818794b684f1
Is trying to build JSON object while returning a raw parameter(uuid) provided.

References to similar problems:

References to the actual line in the code: https://github.com/typestack/routing-controllers/blob/master/src/ActionParameterHandler.ts#L189

Minimal code-snippet showcasing the problem

  @Get('/:id')
  public getProduct(
    @EntityFromParam("id") product: Product,
  ) {
    return product;
  }

Expected behavior

constructed product entity from the UUID

Actual behavior

Error: 
    at new HttpError (/Users/proskuryakovivan/code/byg/byg-admin-core/node_modules/src/http-error/HttpError.ts:16:18)
    at new BadRequestError (/Users/proskuryakovivan/code/byg/byg-admin-core/node_modules/src/http-error/BadRequestError.ts:10:5)
    at new ParameterParseJsonError (/Users/proskuryakovivan/code/byg/byg-admin-core/node_modules/src/error/ParameterParseJsonError.ts:10:5)
    at ActionParameterHandler.parseValue (/Users/proskuryakovivan/code/byg/byg-admin-core/node_modules/src/ActionParameterHandler.ts:194:15)
    at ActionParameterHandler.normalizeParamValue (/Users/proskuryakovivan/code/byg/byg-admin-core/node_modules/src/ActionParameterHandler.ts:139:20)
    at ActionParameterHandler.handle (/Users/proskuryakovivan/code/byg/byg-admin-core/node_modules/src/ActionParameterHandler.ts:39:24)
    at /Users/proskuryakovivan/code/byg/byg-admin-core/node_modules/src/RoutingControllers.ts:114:43
    at Array.map (<anonymous>)
    at RoutingControllers.executeAction (/Users/proskuryakovivan/code/byg/byg-admin-core/node_modules/src/RoutingControllers.ts:114:8)
    at /Users/proskuryakovivan/code/byg/byg-admin-core/node_modules/src/RoutingControllers.ts:82:23
    at routeHandler (/Users/proskuryakovivan/code/byg/byg-admin-core/node_modules/src/driver/express/ExpressDriver.ts:165:14)
    at Layer.handle [as handle_request] (/Users/proskuryakovivan/code/byg/byg-admin-core/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/proskuryakovivan/code/byg/byg-admin-core/node_modules/express/lib/router/route.js:137:13)
    at routeGuard (/Users/proskuryakovivan/code/byg/byg-admin-core/node_modules/src/driver/express/ExpressDriver.ts:179:16)
    at Layer.handle [as handle_request] (/Users/proskuryakovivan/code/byg/byg-admin-core/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/proskuryakovivan/code/byg/byg-admin-core/node_modules/express/lib/router/route.js:137:13)

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs triageIssues which needs to be reproduced to be verified report.type: fixIssues describing a broken feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions