Skip to content

Commit

Permalink
fix(issues): gracefully skip unparseable data
Browse files Browse the repository at this point in the history
- Skip processing issues when the data cannot be parsed
- Prevents errors from halting execution on invalid or malformed data
  • Loading branch information
zachowj committed Sep 6, 2024
1 parent a262507 commit f6e192d
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/nodes/action/issue-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,22 @@ export default function issueCheck(config: ActionNodeProperties): Issue[] {
let data: Record<string, unknown> = {};
try {
data = JSON.parse(config.data || '{}');

if (config.entityId?.length && !data.entity_id) {
const ids = config.entityId.join(', ');
issues.push({
type: IssueType.EntityId,
message: RED._(
'home-assistant.service.issue.entity_id_target_data',
{
entity_id: ids,
},
),
identity: ids,
});
}
} catch (e) {
// fail silently
}
if (config.entityId?.length && !data.entity_id) {
const ids = config.entityId.join(', ');
issues.push({
type: IssueType.EntityId,
message: RED._(
'home-assistant.service.issue.entity_id_target_data',
{
entity_id: ids,
},
),
identity: ids,
});
// if data is not valid JSON we can't check if entity_id is in data so we skip this check
}
}
}
Expand Down

0 comments on commit f6e192d

Please sign in to comment.