Skip to content

Commit

Permalink
Merge pull request #5390 from systeminit/feat/converge-return-if-non-…
Browse files Browse the repository at this point in the history
…unique-keys

feat: add catch in converge for non-unique si-names of components
  • Loading branch information
johnrwatson authored Jan 31, 2025
2 parents 47a4f7a + 7e16b88 commit f535d33
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/sdf-server/src/service/v2/management/generate_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,17 @@ pub async fn generate_template(
}
component_sync_code.push_str(
r#"
// Check for duplicate si names in the abscene of component idempotency keys
const seenNames = new Set<string>();
for (const spec of specs) {
const name = _.get(spec, ["properties", "si", "name"]);
if (seenNames.has(name)) {
throw new Error(`Duplicate properties.si.name found: "${name}", please regenerate the template after fixing the duplicate names or modify the id references in the management function`);
}
seenNames.add(name);
}
return template.converge(currentView, thisComponent, components, specs);
}
"#,
Expand Down

0 comments on commit f535d33

Please sign in to comment.