-
Notifications
You must be signed in to change notification settings - Fork 752
fix(amazonq): Skip including deleted files for FeatureDev context. #6312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "type": "Bug Fix", | ||
| "description": "Amazon Q /dev: Fix issue when files are deleted while preparing context" | ||
| } |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -13,7 +13,7 @@ import { getLogger } from '../../shared/logger/logger' | |||
| import { maxFileSizeBytes } from '../limits' | ||||
| import { createHash } from 'crypto' | ||||
| import { CurrentWsFolders } from '../types' | ||||
| import { ToolkitError } from '../../shared/errors' | ||||
| import { hasCode, ToolkitError } from '../../shared/errors' | ||||
| import { AmazonqCreateUpload, Span, telemetry as amznTelemetry } from '../../shared/telemetry/telemetry' | ||||
| import { TelemetryHelper } from './telemetryHelper' | ||||
| import { maxRepoSizeBytes } from '../constants' | ||||
|
|
@@ -39,7 +39,16 @@ export async function prepareRepoData( | |||
| const ignoredExtensionMap = new Map<string, number>() | ||||
|
|
||||
| for (const file of files) { | ||||
| const fileSize = (await fs.stat(file.fileUri)).size | ||||
| let fileSize | ||||
| try { | ||||
| fileSize = (await fs.stat(file.fileUri)).size | ||||
| } catch (error) { | ||||
| if (hasCode(error) && error.code === 'ENOENT') { | ||||
| // No-op: Skip if file does not exist | ||||
| continue | ||||
| } | ||||
| throw error | ||||
| } | ||||
| const isCodeFile_ = isCodeFile(file.relativeFilePath) | ||||
|
|
||||
| if (fileSize >= maxFileSizeBytes || !isCodeFile_) { | ||||
|
|
@@ -58,7 +67,17 @@ export async function prepareRepoData( | |||
| totalBytes += fileSize | ||||
|
|
||||
| const zipFolderPath = path.dirname(file.zipFilePath) | ||||
| zip.addLocalFile(file.fileUri.fsPath, zipFolderPath) | ||||
|
|
||||
| try { | ||||
| zip.addLocalFile(file.fileUri.fsPath, zipFolderPath) | ||||
| } catch (error) { | ||||
neilk-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
| if (error instanceof Error && error.message.includes('File not found')) { | ||||
| // No-op: Skip if file was deleted or does not exist | ||||
| // Reference: https://github.com/cthackers/adm-zip/blob/1cd32f7e0ad3c540142a76609bb538a5cda2292f/adm-zip.js#L296-L321 | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does it set a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This error does not set a code: https://github.com/cthackers/adm-zip/blob/1cd32f7e0ad3c540142a76609bb538a5cda2292f/util/errors.js#L56 |
||||
| continue | ||||
| } | ||||
| throw error | ||||
| } | ||||
| } | ||||
|
|
||||
| const iterator = ignoredExtensionMap.entries() | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.