Skip to content

Commit

Permalink
Merge pull request #77 from PagerDuty/chore/remove-json-parse-on-pote…
Browse files Browse the repository at this point in the history
…ntial-undefined-bits

chore: refactor JSON.parse usage on unsafe code
  • Loading branch information
t1agob authored Jul 23, 2024
2 parents 49adf3b + d6b4fdf commit 0e93601
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/service/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ export async function createComponentEntitiesReferenceDict({ items: componentEnt
const componentEntitiesDict: Record<string, { ref: string, name: string }> = {};

await Promise.all(componentEntities.map(async (entity) => {
const annotations: Annotations = JSON.parse(JSON.stringify(entity.metadata.annotations));
const serviceId = annotations['pagerduty.com/service-id'];
const integrationKey = annotations['pagerduty.com/integration-key'];
const account = annotations['pagerduty.com/account'] ?? "";
const serviceId = entity.metadata.annotations?.['pagerduty.com/service-id'];
const integrationKey = entity.metadata.annotations?.['pagerduty.com/integration-key'];
const account = entity.metadata.annotations?.['pagerduty.com/account'];

if (serviceId !== undefined && serviceId !== "") {
componentEntitiesDict[serviceId] = {
Expand Down

0 comments on commit 0e93601

Please sign in to comment.