-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[search-documents] getDocument throws TypeError when error response body is undefined #38842
Copy link
Copy link
Open
Labels
ClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.Searchcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamWorkflow: 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 thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
Metadata
Metadata
Assignees
Labels
ClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.Searchcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamWorkflow: 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 thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
StatusShow more project fields
Untriaged
@azure/search-documents13.0.022.14.05.9.3Describe the bug
When
SearchClient.getDocument()is called for a document key that does not exist, Azure Search returns a non-200 response (404) with an empty/undefined response body. The SDK then crashes while deserializing the error response instead of throwing a properRestError.errorResponseDeserializerindist/esm/models/azure/search/documents/models.jsaccessesitem["error"]without checking thatitemis defined._getDocumentDeserializepassesresult.bodydirectly:When
result.bodyisundefined, this throws:Callers expecting a
RestErrorwithstatusCode: 404cannot handle the failure as a normal not-found case.To Reproduce
Steps to reproduce the behavior:
SearchClientfor an existing index (API version defaults to2026-04-01).getDocument()with a key that does not exist in the index.TypeError: Cannot read properties of undefined (reading 'error')instead of aRestErrorwith status code 404.Minimal example:
Expected behavior
The SDK should throw a
RestError(or equivalent Azure client error) withstatusCode: 404when the document is not found, even if the error response body is empty or missing.errorResponseDeserializershould guard againstundefinedinput.Screenshots
N/A
Additional context
errorResponseDeserializer—dist/esm/models/azure/search/documents/models.js:7_getDocumentDeserialize—dist/esm/search/api/operations.js:261getDocument—dist/esm/search/api/operations.js:269errorResponseDeserializer(result.body)) appears in many other operation deserializers, so they may be affected by empty error bodies too.errorResponseDeserializer:import), but the issue is in the SDK's compiled output, not app-specific bundling.