Skip to content

Commit 676db79

Browse files
committed
fix(amazonq): /review shows zero results
Problem: `/review` followed by `Review active file`, always gets zero results from the server. Solution: Roll back the profile-related changes to securityscan-related code. It's unclear why this fixes the issue. This is only a mitigation.
1 parent dad80e5 commit 676db79

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

packages/core/src/codewhisperer/commands/startSecurityScan.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ export async function startSecurityScan(
108108
zipUtil: ZipUtil = new ZipUtil(),
109109
scanUuid?: string
110110
) {
111-
const profile = AuthUtil.instance.regionProfileManager.activeRegionProfile
112111
const logger = getLoggerForScope(scope)
113112
/**
114113
* Step 0: Initial Code Scan telemetry
@@ -188,7 +187,7 @@ export async function startSecurityScan(
188187
const uploadStartTime = performance.now()
189188
const scanName = randomUUID()
190189
try {
191-
artifactMap = await getPresignedUrlAndUpload(client, zipMetadata, scope, scanName, profile)
190+
artifactMap = await getPresignedUrlAndUpload(client, zipMetadata, scope, scanName)
192191
} finally {
193192
await zipUtil.removeTmpFiles(zipMetadata, scope)
194193
codeScanTelemetryEntry.artifactsUploadDuration = performance.now() - uploadStartTime
@@ -213,8 +212,7 @@ export async function startSecurityScan(
213212
artifactMap,
214213
codeScanTelemetryEntry.codewhispererLanguage,
215214
scope,
216-
scanName,
217-
profile
215+
scanName
218216
)
219217
if (scanJob.status === 'Failed') {
220218
logger.verbose(`${scanJob.errorMessage}`)
@@ -237,8 +235,7 @@ export async function startSecurityScan(
237235
scanUuid,
238236
})
239237
}
240-
// pass profile
241-
const jobStatus = await pollScanJobStatus(client, scanJob.jobId, scope, codeScanStartTime, profile)
238+
const jobStatus = await pollScanJobStatus(client, scanJob.jobId, scope, codeScanStartTime)
242239
if (jobStatus === 'Failed') {
243240
logger.verbose(`Security scan failed.`)
244241
throw new CodeScanJobFailedError()
@@ -264,8 +261,7 @@ export async function startSecurityScan(
264261
CodeWhispererConstants.codeScanFindingsSchema,
265262
projectPaths,
266263
scope,
267-
editor,
268-
profile
264+
editor
269265
)
270266
for (const issue of securityRecommendationCollection
271267
.flatMap(({ issues }) => issues)

packages/core/src/codewhisperer/service/securityScanHandler.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
codeScanState,
1414
CodeScanStoppedError,
1515
onDemandFileScanState,
16-
RegionProfile,
1716
} from '../models/model'
1817
import { sleep } from '../../shared/utilities/timeoutUtils'
1918
import * as codewhispererClient from '../client/codewhisperer'
@@ -51,18 +50,13 @@ export async function listScanResults(
5150
codeScanFindingsSchema: string,
5251
projectPaths: string[],
5352
scope: CodeWhispererConstants.CodeAnalysisScope,
54-
editor: vscode.TextEditor | undefined,
55-
profile?: RegionProfile
53+
editor: vscode.TextEditor | undefined
5654
) {
5755
const logger = getLoggerForScope(scope)
5856
const codeScanIssueMap: Map<string, RawCodeScanIssue[]> = new Map()
5957
const aggregatedCodeScanIssueList: AggregatedCodeScanIssue[] = []
6058
const requester = (request: codewhispererClient.ListCodeScanFindingsRequest) => client.listCodeScanFindings(request)
61-
const request: codewhispererClient.ListCodeScanFindingsRequest = {
62-
jobId,
63-
codeAnalysisFindingsSchema: codeScanFindingsSchema,
64-
profileArn: profile?.arn,
65-
}
59+
const request: codewhispererClient.ListCodeScanFindingsRequest = { jobId, codeScanFindingsSchema }
6660
const collection = pageableToCollection(requester, request, 'nextToken')
6761
const issues = await collection
6862
.flatten()
@@ -209,8 +203,7 @@ export async function pollScanJobStatus(
209203
client: DefaultCodeWhispererClient,
210204
jobId: string,
211205
scope: CodeWhispererConstants.CodeAnalysisScope,
212-
codeScanStartTime: number,
213-
profile?: RegionProfile
206+
codeScanStartTime: number
214207
) {
215208
const pollingStartTime = performance.now()
216209
// We don't expect to get results immediately, so sleep for some time initially to not make unnecessary calls
@@ -223,7 +216,6 @@ export async function pollScanJobStatus(
223216
throwIfCancelled(scope, codeScanStartTime)
224217
const req: codewhispererClient.GetCodeScanRequest = {
225218
jobId: jobId,
226-
profileArn: profile?.arn,
227219
}
228220
const resp = await client.getCodeScan(req)
229221
logger.verbose(`GetCodeScanRequest requestId: ${resp.$response.requestId}`)
@@ -250,8 +242,7 @@ export async function createScanJob(
250242
artifactMap: codewhispererClient.ArtifactMap,
251243
languageId: string,
252244
scope: CodeWhispererConstants.CodeAnalysisScope,
253-
scanName: string,
254-
profile?: RegionProfile
245+
scanName: string
255246
) {
256247
const logger = getLoggerForScope(scope)
257248
logger.verbose(`Creating scan job...`)
@@ -263,7 +254,6 @@ export async function createScanJob(
263254
},
264255
scope: codeAnalysisScope,
265256
codeScanName: scanName,
266-
profileArn: profile?.arn,
267257
}
268258
const resp = await client.createCodeScan(req).catch((err) => {
269259
getLogger().error(`Failed creating scan job. Request id: ${err.requestId}`)
@@ -286,8 +276,7 @@ export async function getPresignedUrlAndUpload(
286276
client: DefaultCodeWhispererClient,
287277
zipMetadata: ZipMetadata,
288278
scope: CodeWhispererConstants.CodeAnalysisScope,
289-
scanName: string,
290-
profile?: RegionProfile
279+
scanName: string
291280
) {
292281
const artifactMap = await telemetry.amazonq_createUpload.run(async (span) => {
293282
const logger = getLoggerForScope(scope)
@@ -310,7 +299,6 @@ export async function getPresignedUrlAndUpload(
310299
codeScanName: scanName,
311300
},
312301
},
313-
profileArn: profile?.arn,
314302
}
315303
logger.verbose(`Prepare for uploading src context...`)
316304
const srcResp = await client.createUploadUrl(srcReq).catch((err) => {

0 commit comments

Comments
 (0)