Skip to content

Commit 0033a3c

Browse files
authored
Making sure users can continue editing the UI because something is wrong with validation and this is not reproducible in all machines (#1650)
JIRA: ZAPP-1661
1 parent fd8826d commit 0033a3c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src-electron/validation/validation.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const queryConfig = require('../db/query-config.js')
2727
const queryEndpoint = require('../db/query-endpoint.js')
2828
const types = require('../util/types.js')
2929
const queryPackage = require('../db/query-package.js')
30+
const env = require('../util/env')
3031

3132
/**
3233
* Main attribute validation function.
@@ -52,7 +53,26 @@ async function validateAttribute(
5253
attributeRef,
5354
clusterRef
5455
)
56+
// Null check for endpointAttribute
57+
if (!endpointAttribute) {
58+
env.logWarning(
59+
`validateAttribute called with invalid parameters for endpointAttribute:\n
60+
- endpointTypeId: ${endpointTypeId}\n
61+
- attributeRef: ${attributeRef}\n
62+
- clusterRef: ${clusterRef}`
63+
)
64+
return { defaultValue: ['Attribute not found in endpoint configuration'] }
65+
}
66+
5567
let attribute = await queryZcl.selectAttributeById(db, attributeRef)
68+
// Null check for attribute
69+
if (!attribute) {
70+
env.logWarning(
71+
`validateAttribute called with invalid parameters for attribute:\n
72+
- attributeRef: ${attributeRef}`
73+
)
74+
return { defaultValue: ['Attribute definition not found'] }
75+
}
5676
return validateSpecificAttribute(
5777
endpointAttribute,
5878
attribute,
@@ -118,6 +138,14 @@ async function validateSpecificAttribute(
118138
db,
119139
zapSessionId
120140
) {
141+
if (!endpointAttribute || !attribute) {
142+
env.logWarning(
143+
`validateSpecificAttribute called with invalid parameters:\n
144+
- endpointAttribute: ${JSON.stringify(endpointAttribute)}\n
145+
- attribute: ${JSON.stringify(attribute)}`
146+
)
147+
return { defaultValue: ['Missing attribute or endpoint configuration'] }
148+
}
121149
let defaultAttributeIssues = []
122150
if (attribute.isNullable && endpointAttribute.defaultValue == null) {
123151
return { defaultValue: defaultAttributeIssues }

0 commit comments

Comments
 (0)