fix: ProcessingService create fails with TypeError on project field#1210
fix: ProcessingService create fails with TypeError on project field#1210
Conversation
The serializer had a write-only `project` PrimaryKeyRelatedField that was passed through to ProcessingService.objects.create(), but ProcessingService uses a M2M `projects` field, not a FK. This caused a TypeError on create. The field was left behind when #1094 moved project assignment to perform_create (which uses get_active_project from the query string). Remove the field entirely to match the TaxaList pattern: no writable project field on the serializer, M2M handled in perform_create. Also rename `project` to `project_id` in the frontend's generic convertToServerFieldValues to follow the codebase naming convention (ID values use _id suffix). Closes #1209 Co-Authored-By: Claude <noreply@anthropic.com>
✅ Deploy Preview for antenna-ssec ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for antenna-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📝 WalkthroughWalkthroughFixes a ProcessingService creation error by removing a write-only Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
DRF ignores unknown fields in request body, so no need to strip `project` before passing to the serializer. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes a backend 500 when creating ML processing services by removing an invalid writable project field from the DRF serializer and adding a legacy-body-field cleanup in the view, while attempting to align frontend payload naming to project_id.
Changes:
- Backend: remove stale write-only
projectfield fromProcessingServiceSerializerand drop it fromMeta.fields. - Backend: strip legacy
"project"from POST bodies inProcessingServiceViewSet.create()to avoidTypeErrorfor old clients. - Frontend: rename entity payload field from
projecttoproject_idinconvertToServerFieldValues.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
ui/src/data-services/hooks/entities/utils.ts |
Changes outgoing entity payload from project to project_id. |
ami/ml/views.py |
Drops legacy project key from create payload before serializer validation. |
ami/ml/serializers.py |
Removes invalid writable project field from the processing service serializer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Site, Device, and StorageSource serializers still expect `project` (not `project_id`) as a writable PrimaryKeyRelatedField in the request body. The ProcessingService fix is backend-only — the serializer no longer declares a `project` field, so DRF silently ignores it. Co-Authored-By: Claude <noreply@anthropic.com>

Summary
projectfield fromProcessingServiceSerializerthat causedTypeError: ProcessingService() got unexpected keyword arguments: 'project'when creating a processing service via the APIRoot cause
PR #1094 moved project assignment from the serializer's
create()toperform_create()(which usesget_active_project()from the query string), but left the write-onlyprojectPrimaryKeyRelatedField on the serializer. DRF's defaultcreate()then passed it toProcessingService.objects.create(project=<Project>), which fails becauseProcessingServicehas a M2Mprojectsfield, not a FKproject.Pattern
This now matches the established pattern for M2M project models (TaxaList, Pipeline): no writable project field on the serializer, project assignment handled in
perform_createviaget_active_project()from theproject_idquery parameter.Test plan
convertToServerFieldValuesutil, which is unchanged)Closes #1209
🤖 Generated with Claude Code