Skip to content

Longitude validation checks wrong variable #1053

@mtrezza

Description

@mtrezza

New Issue Checklist

Issue Description

Lines 14-17 and 18-21 validate latitude against longitude bounds instead of validating longitude. This means:

  • Longitude is never validated, allowing invalid coordinates like (0.0, 200.0) to pass.
  • Valid latitudes in the range [90, 180) would incorrectly fail the assertion.

Apply this diff to fix the validation:

     assert(
-      latitude < 180,
+      longitude < 180,
       'Longitude must be within the range (-180.0, 180.0).',
     ),
     assert(
-      latitude > -180,
+      longitude > -180,
       'Longitude must be within the range (-180.0, 180.0).',
     );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      assert(
        longitude < 180,
        'Longitude must be within the range (-180.0, 180.0).',
      ),
      assert(
        longitude > -180,
        'Longitude must be within the range (-180.0, 180.0).',
      );
🤖 Prompt for AI Agents
In packages/dart/lib/src/objects/parse_geo_point.dart around lines 14 to 21, the
two assertion checks are incorrectly validating the variable latitude against
longitude bounds; change both assertions to validate longitude instead (i.e.,
assert(longitude < 180, 'Longitude must be within the range (-180.0, 180.0).')
and assert(longitude > -180, 'Longitude must be within the range (-180.0,
180.0).')), leaving the messages intact so longitude is actually validated and
latitude assertions remain correct elsewhere.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions