From 7e585e24d51da90bd3c08c5651a97d23df9bd7ec Mon Sep 17 00:00:00 2001 From: Darya Plotnytska Date: Tue, 6 Jun 2023 15:10:38 +0200 Subject: [PATCH 1/3] console: Send requests only if version_ids are present --- .../containers/device-payload-formatters/downlink.js | 9 ++++++--- .../containers/device-payload-formatters/uplink.js | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/webui/console/containers/device-payload-formatters/downlink.js b/pkg/webui/console/containers/device-payload-formatters/downlink.js index 81042fbd6f..e3a4743267 100644 --- a/pkg/webui/console/containers/device-payload-formatters/downlink.js +++ b/pkg/webui/console/containers/device-payload-formatters/downlink.js @@ -15,6 +15,7 @@ import React from 'react' import bind from 'autobind-decorator' import { connect } from 'react-redux' +import { isEmpty } from 'lodash' import PAYLOAD_FORMATTER_TYPES from '@console/constants/formatter-types' import tts from '@console/api/tts' @@ -74,9 +75,11 @@ import m from './messages' getRepositoryPayloadFormatters, }, ) -@withRequest(({ appId, device, getRepositoryPayloadFormatters }) => - getRepositoryPayloadFormatters(appId, device.version_ids), -) +@withRequest(({ appId, device, getRepositoryPayloadFormatters }) => { + if (!isEmpty(device.version_ids)) { + return getRepositoryPayloadFormatters(appId, device.version_ids) + } +}) @withBreadcrumb('device.single.payload-formatters.downlink', props => { const { appId, devId } = props diff --git a/pkg/webui/console/containers/device-payload-formatters/uplink.js b/pkg/webui/console/containers/device-payload-formatters/uplink.js index 93ffdebd06..d130837308 100644 --- a/pkg/webui/console/containers/device-payload-formatters/uplink.js +++ b/pkg/webui/console/containers/device-payload-formatters/uplink.js @@ -15,6 +15,7 @@ import React from 'react' import bind from 'autobind-decorator' import { connect } from 'react-redux' +import { isEmpty } from 'lodash' import PAYLOAD_FORMATTER_TYPES from '@console/constants/formatter-types' import tts from '@console/api/tts' @@ -75,9 +76,11 @@ import m from './messages' getRepositoryPayloadFormatters, }, ) -@withRequest(({ appId, device, getRepositoryPayloadFormatters }) => - getRepositoryPayloadFormatters(appId, device.version_ids), -) +@withRequest(({ appId, device, getRepositoryPayloadFormatters }) => { + if (!isEmpty(device.version_ids)) { + return getRepositoryPayloadFormatters(appId, device.version_ids) + } +}) @withBreadcrumb('device.single.payload-formatters.uplink', props => { const { appId, devId } = props From 7c161aa6d5afe3aba9f7c81a542ece03fb5dde61 Mon Sep 17 00:00:00 2001 From: Darya Plotnytska Date: Tue, 6 Jun 2023 15:18:30 +0200 Subject: [PATCH 2/3] dev: Update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f0dfdfd7d..fb00983286 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ For details about compatibility between different releases, see the **Commitment ### Fixed +- Fix payload formatter page launching malformed requests in the Console. + ### Security ## [3.26.0] - unreleased From a9a2a388011bf8c8d28d50f244eca2d3a18bcab8 Mon Sep 17 00:00:00 2001 From: Darya Plotnytska Date: Tue, 6 Jun 2023 17:17:42 +0200 Subject: [PATCH 3/3] dev: Update e2e tests --- .../console/shared/payload-formatters/edit.spec.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cypress/integration/console/shared/payload-formatters/edit.spec.js b/cypress/integration/console/shared/payload-formatters/edit.spec.js index 023af9ef14..36818ca6ca 100644 --- a/cypress/integration/console/shared/payload-formatters/edit.spec.js +++ b/cypress/integration/console/shared/payload-formatters/edit.spec.js @@ -30,6 +30,13 @@ describe('Payload formatters', () => { multicast: false, supports_join: true, lorawan_version: 'MAC_V1_0_2', + version_ids: { + brand_id: 'the-things-products', + model_id: 'the-things-uno', + hw_version: '1.0', + fw_version: 'quickstart', + band_id: 'EU_863_870', + }, ids: { device_id: 'device-all-components', dev_eui: '70B3D57ED8000013', @@ -47,6 +54,11 @@ describe('Payload formatters', () => { }, field_mask: { paths: [ + 'version_ids.brand_id', + 'version_ids.model_id', + 'version_ids.hardware_version', + 'version_ids.firmware_version', + 'version_ids.band_id', 'frequency_plan_id', 'lorawan_phy_version', 'multicast',