amplication
amplication copied to clipboard
🐛 Bug Report:server failed when using a partial update on block settings
What happened?
When trying to update a block by sending just part of its properties, and the block includes a property which is an object, the update fails
you will get the following error
"TypeError: Cannot read properties of undefined (reading 'type')\n at mergeAllSettings (/Users/yuvalhazaz/projects/amplication.git/amplication/dist/packages/amplication-server/webpack:/packages/amplication-server/src/core/block/block.service.ts:505:39)\n at mergeAllSettings (/Users/yuvalhazaz/projects/amplication.git/amplication/dist/packages/amplication-server/webpack:/packages/amplication-server/src/core/block/block.service.ts:509:28)\n at BlockService.update (/Users/yuvalhazaz/projects/amplication.git/amplication/dist/packages/amplication-server/webpack:/packages/amplication-server/src/core/block/block.service.ts:532:25)\n at ModuleActionResolver.updateModuleAction (/Users/yuvalhazaz/projects/amplication.git/amplication/node_modules/@amplication/opentelemetry-nestjs/src/Trace/TraceWrapper.ts:57:18)",
The fix should be to expect some properties on the new object to be undefined
What you expected to happen
The block should be updated successfully. Only the provided properties need to be updated, while all other properties should keep the existing values
How to reproduce
Try to update a block with a property that has an object type, and send other properties for an update. for example
BlockUpdateInput{
enabled:boolean;
otherProp: OtherPropTypeWithInnerProps
}
OtherPropTypeWithInnerProps {
a: string;
b: string;
}
Call the update mutation on the block, and only send a value for the enabled property
you will get the following error
Amplication version
1.12.5.
Environment
No response
Are you willing to submit PR?
No response
@barshimi I assigned it to you. The fix is straight forward and included in the issue description already, however what we are really missing here is a set of comprehensive unit tests for the mergeAllSettings
method that will cover various cases, like this one
✅ passed QA