Problem:ValidateGeometry only checks non-null, serializability, and size limits. Invalid GeoJSON type or malformed coordinate structures can be stored and then fail or mis-deserialize on read paths. Combined with TrailGeometry's LineString-oriented shape, multi-part geometries silently break.
Fix: Validate:
type is in allowlist (LineString, MultiLineString if supported, etc.)
coordinates has correct depth/shape for the declared type
Each coordinate pair has valid lat/lng ranges
Acceptance criteria:
Invalid type rejected before storage
Malformed coordinates rejected before storage
Unit tests cover invalid-type, invalid-shape, invalid-range cases
**Severity:** Medium (data integrity)
**File:** `SpikerSoft.Business/Domain/Map/Trails/Validation/TrailValidator.cs` (~148-176)
**Problem:** `ValidateGeometry` only checks non-null, serializability, and size limits. Invalid GeoJSON `type` or malformed coordinate structures can be stored and then fail or mis-deserialize on read paths. Combined with `TrailGeometry`'s LineString-oriented shape, multi-part geometries silently break.
**Fix:** Validate:
- `type` is in allowlist (`LineString`, `MultiLineString` if supported, etc.)
- `coordinates` has correct depth/shape for the declared type
- Each coordinate pair has valid lat/lng ranges
**Acceptance criteria:**
- [ ] Invalid `type` rejected before storage
- [ ] Malformed coordinates rejected before storage
- [ ] Unit tests cover invalid-type, invalid-shape, invalid-range cases
TrailValidator.ValidateGeometry now performs structural GeoJSON validation:
Allowlists type against { LineString, MultiLineString }
Verifies coordinates is an array with the correct depth/shape for the declared type
New helper ValidateLineStringCoordinates enforces ≥ 2 coordinates, ≤ MaxCoordinatesCount, each pair has 2-3 numeric components, and uses the existing ValidateCoordinate for lat/lng range checks
MultiLineString validates total coordinate count across all lines
Existing size-limit and serialization checks retained
**Resolved.**
`TrailValidator.ValidateGeometry` now performs structural GeoJSON validation:
- Allowlists `type` against `{ LineString, MultiLineString }`
- Verifies `coordinates` is an array with the correct depth/shape for the declared type
- New helper `ValidateLineStringCoordinates` enforces ≥ 2 coordinates, ≤ `MaxCoordinatesCount`, each pair has 2-3 numeric components, and uses the existing `ValidateCoordinate` for lat/lng range checks
- `MultiLineString` validates total coordinate count across all lines
- Existing size-limit and serialization checks retained
File: `SpikerSoft.Business/Domain/Map/Trails/Validation/TrailValidator.cs`.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Severity: Medium (data integrity)
File:
SpikerSoft.Business/Domain/Map/Trails/Validation/TrailValidator.cs(~148-176)Problem:
ValidateGeometryonly checks non-null, serializability, and size limits. Invalid GeoJSONtypeor malformed coordinate structures can be stored and then fail or mis-deserialize on read paths. Combined withTrailGeometry's LineString-oriented shape, multi-part geometries silently break.Fix: Validate:
typeis in allowlist (LineString,MultiLineStringif supported, etc.)coordinateshas correct depth/shape for the declared typeAcceptance criteria:
typerejected before storageResolved.
TrailValidator.ValidateGeometrynow performs structural GeoJSON validation:typeagainst{ LineString, MultiLineString }coordinatesis an array with the correct depth/shape for the declared typeValidateLineStringCoordinatesenforces ≥ 2 coordinates, ≤MaxCoordinatesCount, each pair has 2-3 numeric components, and uses the existingValidateCoordinatefor lat/lng range checksMultiLineStringvalidates total coordinate count across all linesFile:
SpikerSoft.Business/Domain/Map/Trails/Validation/TrailValidator.cs.