Skip to content

Conversation

@OrangeAndGreen
Copy link
Contributor

@OrangeAndGreen OrangeAndGreen commented Jan 29, 2026

https://dimagi.atlassian.net/browse/QA-8360

Product Description

Fixes a bug where the map would crash if errors in the map data (such as incorrectly formatted GPS points) caused there to be no valid coordinates. Now, the map appears with the error message indicating something went wrong.

Technical Summary

Checking to make sure at least one coordinate was added to the map before attempting to build bounds.
Later, the map is only zoomed after loading if bounds were calculated.

Stack trace of prior crash:

Fatal Exception: java.lang.IllegalStateException: no included points
       at com.google.android.gms.common.internal.Preconditions.checkState(com.google.android.gms:play-services-basement@@18.3.0:2)
       at com.google.android.gms.maps.model.LatLngBounds$Builder.build(com.google.android.gms:play-services-maps@@19.2.0:1)
       at org.commcare.gis.EntityMapActivity.onMapReady(EntityMapActivity.java:193)
       at com.google.android.gms.maps.zzau.zzb(com.google.android.gms:play-services-maps@@19.2.0:1)
       at com.google.android.gms.maps.internal.zzas.zza(com.google.android.gms:play-services-maps@@19.2.0:5)
       at com.google.android.gms.internal.maps.zzb.onTransact(com.google.android.gms:play-services-maps@@19.2.0:3)
       at android.os.Binder.transact(Binder.java:1190)
       at m140.ayh.c(:com.google.android.gms.policy_maps_core_dynamite@254515607@254515602025.843324832.843324832:8)
       at com.google.maps.api.android.lib6.impl.bz.run(:com.google.android.gms.policy_maps_core_dynamite@254515607@254515602025.843324832.843324832:17)
       at android.os.Handler.handleCallback(Handler.java:958)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:222)
       at android.os.Looper.loop(Looper.java:314)
       at android.app.ActivityThread.main(ActivityThread.java:8670)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:565)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)

Feature Flag

None

Safety Assurance

Safety story

I was able to reproduce the crash before applying the fix.
After applying the fix, the crash no longer occurs and instead the map loads with an error message.

Automated test coverage

None

QA Plan

See the linked ticket for details on a QA test user that was crashing before.
Test loading the map with that user and verify there's no crash.

@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

The change modifies three helper methods in EntityMapActivity.java to return boolean values instead of void, tracking whether each method successfully adds map elements. An aggregate flag combines these results to determine if map bounds should be calculated and whether camera animation should execute. Camera movement now occurs conditionally only when bounds exist, and error handling in the marker addition path returns false instead of silently terminating the method.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

skip-integration-tests

Suggested reviewers

  • shubham1g5
  • conroy-ricketts
  • Jignesh-dimagi
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main change: fixing a map crash caused by data errors, which aligns with the technical changes that prevent crashes when no valid coordinates exist.
Description check ✅ Passed The pull request description includes all major required sections with sufficient detail: product description explaining the bug fix, technical summary with rationale and a helpful stack trace, safety assurance with testing approach, and appropriate labels/review guidance.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dv/fix/qa-8360-empty-map-data

Tip

🧪 Unit Test Generation v2 is now available!

We have significantly improved our unit test generation capabilities.

To enable: Add this to your .coderabbit.yaml configuration:

reviews:
  finishing_touches:
    unit_tests:
      enabled: true

Try it out by using the @coderabbitai generate unit tests command on your code files or under ✨ Finishing Touches on the walkthrough!

Have feedback? Share your thoughts on our Discord thread!


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/src/org/commcare/gis/EntityMapActivity.java (1)

270-299: Skip empty boundaries to avoid bounds build crash.

If getBoundary() returns a non-null but empty list (possible with invalid data), no coordinates are included, yet the method returns true. That makes added true and can still trigger builder.build() with no points, which will throw. Guard against empty boundaries and return false in that case.

Proposed fix
-        if (displayInfo.getBoundary() != null) {
+        if (displayInfo.getBoundary() != null && !displayInfo.getBoundary().isEmpty()) {
             int color = displayInfo.getBoundaryColorHex() != null ?
                     displayInfo.getBoundaryColorHex() :
                     Color.WHITE;
@@
             numPolygons++;
             return true;
         }
 
         return false;

Copy link
Contributor

@shubham1g5 shubham1g5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am finding it hard to identify where the code was crashing due to invalid co-ordinates based on the solution here, can we please add the stacktrace for the crash.

@OrangeAndGreen
Copy link
Contributor Author

@shubham1g5 No problem, added the stack trace. Specifically the problem was calling LatLngBounds.Builder.build() without ever adding any points to the builder

@OrangeAndGreen OrangeAndGreen merged commit 0487409 into master Jan 30, 2026
9 checks passed
@OrangeAndGreen OrangeAndGreen deleted the dv/fix/qa-8360-empty-map-data branch January 30, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants