Repository navigation
fix(amazon-location-service): fix sample bugs from the #250 review - #294
Open
TheSaiEaranti wants to merge 7 commits into
Open
TheSaiEaranti wants to merge 7 commits into
TheSaiEaranti wants to merge 7 commits into
Conversation
waitForJob polled GetJob in a while (true) with no deadline. A ThrottlingException that outlasted the SDK's own retries ended the wait, and the "back off" comment sat above a constant 30 s sleep. It now takes maxWaitMs (6 hours by default), keeps polling through ThrottlingException and InternalServerException, backs off from 30 s up to 5 minutes, and throws once the deadline passes. The prose points long-running jobs and Lambda callers at EventBridge, and the GetJob error list names the transient errors. triage() used !mailable, so it rejected every record with no Mailable value. It now sends those records to review, along with any record that has an ErrorType, and the delivery indicators line says to treat a missing value as unknown.
The Android route display sample mapped routePoints, which is never defined, and read each element as Pair(lat, lon). It now calls CalculateRoutes with legGeometryFormat set to GeometryFormat.Simple and builds the line from each leg's lineString, which is already in [lng, lat] order. geometry and lineString are nullable in the georoutes model classes, so the access uses ?. and orEmpty(). The default format, FlexiblePolyline, fills geometry.polyline instead of lineString, and the comment says so.
The map load block and the live poll in device-tracking.md read only the first page of ListDevicePositions, although the same file says to follow NextToken. The live poll also used an async setInterval callback, so a slow or throttled poll could still be running when the next one started, and an older response could be applied after a newer one. Add listAllDevicePositions(), which follows NextToken, and use it in both blocks. The live poll is now a loop that schedules the next poll 15 seconds after the current one finishes, and catches a failed poll so the loop keeps going. The history block also follows NextToken now, as the Best Practices list asks.
MapActivity created a MapView but never called mapView.onCreate and forwarded none of the other lifecycle calls, which MapLibre's MapView javadoc says must come from the parent Activity or Fragment. Call mapView.onCreate(savedInstanceState) after setContentView, and override onStart, onResume, onPause, onStop, onSaveInstanceState, onLowMemory and onDestroy to forward them. The style URL also used $API_KEY, which is a private constant inside AmazonLocationAuth's companion object, so the sample did not compile. It now uses an apiKey placeholder property.
The numbered items under "When to Use Simple Format" and "When to Use FlexiblePolyline Format" kept their code fences, prose and sub-bullets at column 0. That ends the list after every item, so each section rendered as a run of one-item lists that all showed "1.". Indent each item body by 3 spaces so each section is one list, and number the items 1-5 and 1-6. Numbering alone would fail MD029, which wants each of those one-item lists to start at 1. The code inside the fences is unchanged. Also turn the "##### Bandwidth savings: ..." heading back into a sentence, now with a bold label.
The Option B sample in zone-alerts.md discarded the response, so per-device failures reported in its Errors array went unnoticed, although the Batch Operation Errors section of the same file says to always check that array. Keep the response and log each failed device, the same way device-tracking.md does for BatchUpdateDevicePosition.
TheSaiEaranti
requested review from
a team,
arnewouters,
krokoko and
laithalsaadoon
October 28, 2026 22:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the six follow-ups that #269 tracks from the #250 review. Five are bugs in the JavaScript and Kotlin samples in the amazon-location-service references, and one is a pair of numbered lists in
calculate-routes.mdthat show every item as "1.". Each item is its own commit, followed by the version bump.Related
Fixes #269, which collects the review follow-ups from #250.
Changes
address-verification.md:waitForJoblooped onGetJobwith no deadline, aThrottlingExceptionthat outlasted the SDK's retries ended the wait, and the "back off" comment sat above a fixed 30 s sleep. It now takesmaxWaitMs(6 hours by default), keeps polling throughThrottlingExceptionandInternalServerException, backs off from 30 s to 5 minutes, and throws at the deadline. The text above it now points long-running jobs and Lambda callers at EventBridge.triage()tested!mailable, so every record without aMailablevalue was rejected. It now sends those records, and records with anErrorType, to review, and the delivery indicators line says to treat a missing value as unknown. I went that way because the Amazon Location docs only listtrue/falsefor these columns and don't say whether they are always present. If you know they are, that sentence can just say so.google-migration-android.md, Pattern 3:routePointswas never defined, andPoint.fromLngLat(it.second, it.first)assumed(lat, lon)pairs. The sample now callscalculateRouteswithlegGeometryFormat = GeometryFormat.Simpleand maps each leg'slineString, which is already[lng, lat]. I didn't use the line suggested in amazon-location-service: follow-ups from #250 review #269 as written. It doesn't compile against georoutes 1.8.51, wheregeometryandlineStringare nullable, andlineStringis only filled when the request asks forSimple(the default,FlexiblePolyline, returnsgeometry.polyline).google-migration-web.mdalready recommendsSimplefor migrations.device-tracking.md: themap.on("load")block and the live poll read only the first page ofListDevicePositions(at most 100 devices), and the asyncsetIntervalcallback could start a poll while a slow one was still running, so older positions could be applied after newer ones. AlistAllDevicePositions()helper now followsNextToken, both blocks use it, and the poll is a loop that schedules the next run 15 s after the previous one finishes and logs a failed poll. Beyond the list in amazon-location-service: follow-ups from #250 review #269, I also paginated the history block, which had the same one-page gap that the Best Practices list in this file warns about. It is one hunk if you'd rather leave it out.google-migration-android.md,MapActivity: it never calledmapView.onCreate(savedInstanceState)and didn't forward the other lifecycle calls that the MapLibre 13.1.0MapViewjavadoc says must come from the parent Activity. It now callsonCreatebeforegetMapAsyncand overridesonStart,onResume,onPause,onStop,onSaveInstanceState,onLowMemoryandonDestroyin the order from the review. Also beyond the list: the style URL used$API_KEY, aprivate constinsideAmazonLocationAuth's companion object, so the class didn't compile. It now has its ownapiKeyplaceholder, which is also easy to drop.calculate-routes.md: the item bodies under "When to Use Simple Format" and "When to Use FlexiblePolyline Format" were at column 0, which closes the list after every item, so all 11 items rendered as "1.". Explicit numbers alone fail MD029 here (9 errors, since each one-item list has to start at 1), so I indented each item body by 3 spaces and numbered the items 1-5 and 1-6. The diff is nearly all whitespace and is easiest to read with whitespace hidden (?w=1), where it is 10 lines. The##### Bandwidth savingsheading is a sentence again, now with a bold label.zone-alerts.md: theBatchEvaluateGeofencessample threw away the response. It now checksresponse.Errorsand logs each failed device, as the Batch Operation Errors section of the same file says to..claude-plugin/marketplace.jsonand both plugin manifests.Verification:
@aws-sdk/client-location3.1159.0, with a stubbed HTTP handler and a fake clock.Runningis still polled after 72 simulated hours, and 3 throttled responses in a row end the wait. 250 devices give 100 markers, and a slow poll overlaps the next one and moves markers back to older positions. A failedBatchEvaluateGeofencesentry prints nothing.node --checkon each changed block, andtsc --checkJs(5.9.3 and 7.0.2) against the SDK and maplibre-gl 5.24.0 types: no errors beyond the two that main already has on lines this doesn't change.MapActivitysamples with kotlinc 2.4.21 against android.jar 35,org.maplibre.gl:android-sdk:13.1.0,android-plugin-annotation:4.0.0,androidx.appcompat:appcompat:1.7.0andaws.sdk.kotlin:georoutes-jvm:1.8.51, adding only the imports and enclosing function the snippets assume. Main fails withunresolved reference 'routePoints'andunresolved reference 'API_KEY', and this branch compiles with no warnings. I only compiled them. I didn't run either sample on a device or emulator.calculate-routes.md: markdown-it 15.0.3, commonmark.js 0.31.2 and cmark-gfm (cmarkgfm 2025.10.22) render 11 one-item lists on main and two lists numbered 1-5 and 1-6 on this branch. The 41 fenced code blocks have the same content before and after.markdownlint-cli20.17.2,dprint check, thelint:manifestsajv checks,node tools/validate-cross-refs.cjs,uv run tools/validate-references.py,uv run tools/validate-size.pyanduv run --with pytest pytest tools plugins(132 passed): all pass, with the same output as on main.Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.