Fix PATCH /api/application/nodes returning 500 due to null timestamps#2286
Fix PATCH /api/application/nodes returning 500 due to null timestamps#2286NeilHanlon wants to merge 1 commit intopelican-dev:mainfrom
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe NodeUpdateService was changed to inject explicit Changes
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I have read the CLA Document and I hereby sign the CLA |
The NodeUpdateService uses replicate() to create a copy of the node model before updating it. replicate() strips timestamp fields, and after forceFill()->save(), the in-memory model still has null values for created_at and updated_at. When the NodeTransformer calls formatTimestamp() on these null values, it triggers a TypeError because the method expects a non-nullable string. Adding refresh() after save() reloads the model from the database, ensuring timestamps are properly populated before the response is serialized.
ef7f79a to
0e60153
Compare
The
NodeUpdateServiceusesreplicate()to create a copy of the node model before updating it.replicate()strips timestamp fields, and afterforceFill()->save(), the in-memory model still has null values for created_at and updated_at. When theNodeTransformercallsformatTimestamp()on these null values, it triggers a TypeError because the method expects a non-nullable string.Adding
refresh()aftersave()reloads the model from the database, ensuring timestamps are properly populated before the response is serialized.This was discovered when attempting to programmatically update nodes using the API, which reliably reproduces the following error: