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

Cannot destructure property 'parsed' of 'req' as it is null. #830

Closed
neutron92 opened this issue Jul 24, 2023 · 9 comments
Closed

Cannot destructure property 'parsed' of 'req' as it is null. #830

neutron92 opened this issue Jul 24, 2023 · 9 comments

Comments

@neutron92
Copy link

neutron92 commented Jul 24, 2023

Bug Report

Current behavior

when i open http://localhost:3333/users in my browser to get list of users i have 500 and the error in the console

image

in the POST
image

The req argument all the time is null

Input Code

// controller
@Crud({
  model: {
    type: User,
  },
  query: {
    alwaysPaginate: true,
  },
  serialize,
  dto,
  validation: {
    transform: true,
  },
})
@Feature('users')
@ApiTags('users')
@Controller('users')
export class UsersController implements CrudController<User> {
  constructor(public service: UsersService) {}
}

//Module
@Module({
  imports: [TypeOrmModule.forFeature([User])],
  controllers: [UsersController],
  providers: [UsersService],
})
export class UsersModule {}

//Service
@Injectable()
export class UsersService extends TypeOrmCrudService<User> {
  constructor(@InjectRepository(User) readonly repo) {
    super(repo);
  }
}

//Main
CrudConfigService.load();

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule, {
    cors: true,
  });

  app.useGlobalFilters(new HttpExceptionFilter());
  app.use(cookieParser());
  app.use(json({ limit: '150mb' }));
  app.use(urlencoded({ extended: true, limit: '150mb' }));

  SwaggerConfig(app, AppModule.apiVersion);

  await app.listen(AppModule.port, AppModule.host);
}
bootstrap();

Expected behavior

it works

Possible Solution

Environment


image

Repository with minimal reproduction

@lan-nguyen91
Copy link

@neutron92 , how did you fix this issue ?

@neutron92
Copy link
Author

I'm struggling with updating nestjs to v10 in existing project and hit the wall with this repo not being maintained anymore. There is a fork that looks well maintained here: https://github.com/gid-oss/dataui-nestjs-crud

@henrytsui
Copy link

i face same issue, please reopen this issue

@fsoubes
Copy link

fsoubes commented Jul 31, 2023

Same here
Do you have any news to bypass this issue ?

@neutron92
Copy link
Author

I'm struggling with updating nestjs to v10 in existing project and hit the wall with this repo not being maintained anymore. There is a fork that looks well maintained here: https://github.com/gid-oss/dataui-nestjs-crud

@MikhaelGerbet
Copy link

I'm struggling with updating nestjs to v10 in existing project and hit the wall with this repo not being maintained anymore. There is a fork that looks well maintained here: https://github.com/gid-oss/dataui-nestjs-crud

saved my project bud ! Thx

@khiami
Copy link

khiami commented Sep 15, 2023

Overriding the base route fixes the issue!.. but I mean this is not a proper fix.. since I believe we're are not supposed to override unless there's a reason. The latest update I think breaks the chain where @Controller extends the class.

@danielsharvey
Copy link

The underlying cause is #825. My workaround (from here):

If you are using @rewiko/crud, use patch-package to handle the NestJS change.

For context, this is the issue: nestjs/nest#11450 (a constant CUSTOM_ROUTE_AGRS_METADATA was misspelt a while back and finally removed - the correct spelling is now used - CUSTOM_ROUTE_ARGS_METADATA).

Here is my patch:

@rewiko+crud+5.1.12.patch

@ihazar
Copy link

ihazar commented Mar 13, 2024

Same issue here also:

ERROR [ExceptionsHandler] Cannot destructure property 'parsed' of 'req' as it is null.
TypeError: Cannot destructure property 'parsed' of 'req' as it is null.
    at ScanMetadataService.getMany (/node_modules/@nestjsx/crud-typeorm/src/typeorm-crud.service.ts:99:13)
    at ScanMetadataController.getManyBase (/node_modules/@nestjsx/crud/src/crud/crud-routes.factory.ts:215:27)
    at /node_modules/@nestjs/core/router/router-execution-context.js:38:29
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

I downgraded from nestjs 10.3.3 to 9.4.3 @nestjs/[email protected] @nestjs/[email protected] and it worked.

Or of course, use a more maintained crud library as mentioned above:

npm uninstall @nestjsx/crud @nestjsx/crud-typeorm
npm i --save @dataui/crud @dataui/crud-typeorm

And change all imports from '@nestjsx/crud' and from '@nestjsx/crud-typeorm' to '@dataui/crud' and '@dataui/crud-typeorm'respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants