Skip to content

Deserialization Error in RouteMatrixResultResponse When Error String is Returned Instead of Null #45643

@ChristopherErbs

Description

@ChristopherErbs

Library name and version

Azure Maps Routing API Version: 1.0

Describe the bug

When submitting a Post Route Matrix Request I encountered a deserialization issue with the RouteMatrixResult API when a distance to one of the destinations cannot be resolved. Specifically, the API returns a serialized RouteMatrixResult containing an array of RouteMatrixes. Each RouteMatrix holds a RouteMatrixResultResponse, which in turn contains a RouteLegSummary.

However, when the distance to a destination cannot be resolved, the response field in the RouteMatrixResultResponse is returned as an error string instead of a null value for the RouteMatrixResultResponse object. This causes a deserialization error on the client side, which currently requires manual handling.

Example json:

{
	"formatVersion": "0.0.1",
	"matrix": [
		[
			{
				"statusCode": 400,
				"response": "Engine error while executing route request: MAP_MATCHING_FAILURE: Destination (1, 13.5471)",
				"detailedError": {
					"message": "Engine error while executing route request: MAP_MATCHING_FAILURE: Destination (1, 13.5471)",
					"code": "MAP_MATCHING_FAILURE"
				}
			},
			{
				"statusCode": 200,
				"response": {
					"routeSummary": {
						"lengthInMeters": 264939,
						"travelTimeInSeconds": 10394,
						"trafficDelayInSeconds": 191,
						"trafficLengthInMeters": 16648,
						"departureTime": "2024-08-21T09:31:41+02:00",
						"arrivalTime": "2024-08-21T12:24:55+02:00"
					}
				}
			},
			{
				"statusCode": 200,
				"response": {
					"routeSummary": {
						"lengthInMeters": 305985,
						"travelTimeInSeconds": 11207,
						"trafficDelayInSeconds": 191,
						"trafficLengthInMeters": 16648,
						"departureTime": "2024-08-21T09:31:41+02:00",
						"arrivalTime": "2024-08-21T12:38:28+02:00"
					}
				}
			}
		]
	]
}

n the example above, the first entry in the matrix array returns an error string under the response field, which causes a deserialization failure on the client side.

Expected behavior

The response field should return a null value or an appropriately structured error object instead of a plain error string when a distance cannot be resolved. This would prevent deserialization errors and allow the client to handle errors more gracefully.

Actual behavior

Deserialization fails

Reproduction Steps

Steps to Reproduce:

  1. Make a request to the RouteMatrix API with a destination that cannot be resolved.
  2. Observe the response field in the RouteMatrixResultResponse for the destination.
  3. Attempt to deserialize the response into the expected object model.

Environment

.NET6, VS Version 17.10.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue is related to a non-management packageMapsService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions