Skip to content

Commit

Permalink
fix: ignore missing targets when multiple orgs are used and rename di…
Browse files Browse the repository at this point in the history
…splay name attribute to fit
  • Loading branch information
Roshick committed Mar 6, 2024
1 parent 176e0c4 commit c65cfeb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,14 @@ export class SnykApiClient implements SnykApi {
}
const jsonResponse = await response.json();
return jsonResponse.data as ProjectsData[];
} else {
} else if (!ignoreMissing) {
throw new Error(
`No target IDs found in org ${orgId} for the targets [${repoName.join(
","
)}].`
);
} else {
return [];
}
}

Expand Down Expand Up @@ -452,7 +454,7 @@ export class SnykApiClient implements SnykApi {
const targetsList = await targetResponse.json();
const targetsListData = targetsList.data as TargetData[];
targetId = targetsListData.find((target) => {
return target.attributes.displayName === targetIdentifier;
return target.attributes.display_name === targetIdentifier;
})?.id;
if (!targetId) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion src/types/targetsTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface TargetDataAttributes {
* @type {string}
* @memberof TargetDataAttributes
*/
displayName?: string;
display_name?: string;
/**
* The URL for the resource. We do not use this as part of our representation of the identity of the target, as it can be changed externally to Snyk We are reliant on individual integrations providing us with this value. Currently it is only provided by the CLI
* @type {string}
Expand Down

0 comments on commit c65cfeb

Please sign in to comment.