Is your feature request related to a problem? Please describe.
The POST /api/v1/observations/import endpoint currently allows creating observation points without coordinates even when no cave is associated. This results in orphan points that cannot be placed on a map.
Related frontend issue: GrottoCenter/grottocenter-front#1412
Describe the solution you'd like
Add server-side validation to the observations import endpoint:
- When the submitted profile has
locationMode: 'pointOnly' (or when no caveId is provided), reject the request with HTTP 400 if latitude or longitude is null/missing.
- Error response should include a clear validation error code and message indicating that coordinates are required for standalone points.
This ensures data integrity regardless of which client submits the data.
Describe alternatives you've considered
- Relying solely on frontend validation — rejected because API consumers could bypass it.
- Adding a database-level CHECK constraint — possible but the constraint logic depends on
locationMode which is a profile-level concept, not a column. Better handled at the application layer.
Additional context
- The frontend already has the concept of
locationMode with three values: pointAndCave, pointOnly, caveOnly
- The
locationMode field is included in the profile JSON sent as part of the multipart form submission
- Rule: if
locationMode === 'pointOnly' → lat/lng must be non-null
- Rule: if
locationMode === 'pointAndCave' or caveOnly → lat/lng remain optional
Is your feature request related to a problem? Please describe.
The
POST /api/v1/observations/importendpoint currently allows creating observation points without coordinates even when no cave is associated. This results in orphan points that cannot be placed on a map.Related frontend issue: GrottoCenter/grottocenter-front#1412
Describe the solution you'd like
Add server-side validation to the observations import endpoint:
locationMode: 'pointOnly'(or when nocaveIdis provided), reject the request with HTTP 400 iflatitudeorlongitudeis null/missing.This ensures data integrity regardless of which client submits the data.
Describe alternatives you've considered
locationModewhich is a profile-level concept, not a column. Better handled at the application layer.Additional context
locationModewith three values:pointAndCave,pointOnly,caveOnlylocationModefield is included in the profile JSON sent as part of the multipart form submissionlocationMode === 'pointOnly'→ lat/lng must be non-nulllocationMode === 'pointAndCave'orcaveOnly→ lat/lng remain optional