fix: client side errors from unexpected null/undefined values #3129
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.
Overview
This PR contains possible fixes for two types of client side errors.
(1) We received type errors that could not be reproduced that look like this:
error: Cannot read properties of null (reading 'getCoordinateSystems') stackTrace: TypeError: Cannot read properties of null (reading 'getCoordinateSystems')
This means that the ExtensionAPI was null somewhere in the code. Adding these null checks (
!api
) are harmless and will hopefully prevent these errors from occurring again.(2) We received another type error when trying to read
$metadata
:error: Cannot read properties of undefined (reading 'httpStatusCode') stackTrace: TypeError: Cannot read properties of undefined (reading 'httpStatusCode')
Changes for this include explicitly typing errors as
IoTSiteWiseServiceExceptions
and setting theerrorCode
to the error name (it was never supposed to be the http status code in the first place)Verifying Changes
npm run test
in source-iotsitewise package was successfulLegal
This project is available under the Apache 2.0 License.