Cannot destructure property 'parsed' of 'req' as it is null.
neutron92 opened this issue ยท 9 comments
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
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
Repository with minimal reproduction
@neutron92 , how did you fix this issue ?
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
i face same issue, please reopen this issue
Same here
Do you have any news to bypass this issue ?
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
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
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.
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:
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/core@9.4.3 @nestjs/common@9.4.3
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.