From 35c684e95266f93d05cca4822b0e54b69820c57e Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Wed, 2 Aug 2023 06:26:09 -0700 Subject: [PATCH 1/2] fix: limits are enforced server-side. While 12 is the default, it can be increased on request, and enforcement on the client-side becomes incorrect. --- CHANGELOG.md | 2 ++ docs/services.md | 2 +- services/__tests__/optimization.test.js | 2 +- services/optimization.js | 6 +++--- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4db271e..8adac251 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- **Fix:** Maximum Optimization V1 request size limits should not be enforced client-side + ## 0.15.2 - **Add:** Add `depart_at` and `arrive_by` as optional parameters in the directions service diff --git a/docs/services.md b/docs/services.md index a37ec6b7..d3ccf97c 100644 --- a/docs/services.md +++ b/docs/services.md @@ -1988,7 +1988,7 @@ to understand all of the available options. * `config` **[Object][207]** * `config.profile` **(`"driving"` | `"driving-traffic"` | `"walking"` | `"cycling"`)** (optional, default `"driving"`) - * `config.waypoints` **[Array][216]<[OptimizationWaypoint][180]>** An ordered array of [`OptimizationWaypoint`][180] objects, between 2 and 12 (inclusive). + * `config.waypoints` **[Array][216]<[OptimizationWaypoint][180]>** An ordered array of [`OptimizationWaypoint`][180] objects, with at least 2 * `config.annotations` **[Array][216]<(`"duration"` | `"distance"` | `"speed"`)>?** Specify additional metadata that should be returned. * `config.destination` **(`"any"` | `"last"`)** Returned route ends at `any` or `last` coordinate. (optional, default `"any"`) * `config.distributions` **[Array][216]<[Distribution][203]>?** An ordered array of [`Distribution`][203] objects, each of which includes a `pickup` and `dropoff` property. `pickup` and `dropoff` properties correspond to an index in the OptimizationWaypoint array. diff --git a/services/__tests__/optimization.test.js b/services/__tests__/optimization.test.js index 97c31219..c9c03015 100644 --- a/services/__tests__/optimization.test.js +++ b/services/__tests__/optimization.test.js @@ -103,7 +103,7 @@ describe('getOptimization', () => { }, error => { expect(error.message).toMatch( - 'waypoints must include between 2 and 12 OptimizationWaypoints' + 'waypoints must include at least 2 OptimizationWaypoints' ); } ); diff --git a/services/optimization.js b/services/optimization.js index 55e5ebbb..9f4f59a7 100644 --- a/services/optimization.js +++ b/services/optimization.js @@ -21,7 +21,7 @@ var Optimization = {}; * * @param {Object} config * @param {'driving'|'driving-traffic'|'walking'|'cycling'} [config.profile="driving"] - * @param {Array} config.waypoints - An ordered array of [`OptimizationWaypoint`](#optimizationwaypoint) objects, between 2 and 12 (inclusive). + * @param {Array} config.waypoints - An ordered array of [`OptimizationWaypoint`](#optimizationwaypoint) objects, with at least 2 * @param {Array<'duration'|'distance'|'speed'>} [config.annotations] - Specify additional metadata that should be returned. * @param {'any'|'last'} [config.destination="any"] - Returned route ends at `any` or `last` coordinate. * @param {Array} [config.distributions] - An ordered array of [`Distribution`](#distribution) objects, each of which includes a `pickup` and `dropoff` property. `pickup` and `dropoff` properties correspond to an index in the OptimizationWaypoint array. @@ -72,9 +72,9 @@ Optimization.getOptimization = function(config) { }; var waypointCount = config.waypoints.length; - if (waypointCount < 2 || waypointCount > 12) { + if (waypointCount < 2) { throw new Error( - 'waypoints must include between 2 and 12 OptimizationWaypoints' + 'waypoints must include at least 2 OptimizationWaypoints' ); } From cecd173100b6783558766b4645de64eda191bfd5 Mon Sep 17 00:00:00 2001 From: Connor Brown Date: Wed, 2 Aug 2023 09:53:14 -0400 Subject: [PATCH 2/2] no edits to changelogs in PRs --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8adac251..f4db271e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,6 @@ ## Unreleased -- **Fix:** Maximum Optimization V1 request size limits should not be enforced client-side - ## 0.15.2 - **Add:** Add `depart_at` and `arrive_by` as optional parameters in the directions service