Skip to content

Commit

Permalink
fix(amazonq): fix uploading file method error handling for /doc
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinDing1 committed Feb 24, 2025
1 parent 4421290 commit bf8700f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "Amazon Q /doc: Fix uploading file method throwing incorrect workspace too large error message"
}
5 changes: 5 additions & 0 deletions packages/core/src/amazonq/util/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '../../shared/utilities/workspaceUtils'

import { ContentLengthError, PrepareRepoFailedError } from '../../amazonqFeatureDev/errors'
import { ContentLengthError as DocContentLengthError } from '../../amazonqDoc/errors'
import { getLogger } from '../../shared/logger/logger'
import { maxFileSizeBytes } from '../../amazonqFeatureDev/limits'
import { CurrentWsFolders, DeletedFileInfo, NewFileInfo, NewFileZipContents } from '../../amazonqDoc/types'
Expand Down Expand Up @@ -48,6 +49,7 @@ export type PrepareRepoDataOptions = {
telemetry?: TelemetryHelper
zip?: ZipStream
isIncludeInfraDiagram?: boolean
featureName?: 'featureDev' | 'docGeneration'
}

/**
Expand Down Expand Up @@ -186,6 +188,9 @@ export async function prepareRepoData(
} catch (error) {
getLogger().debug(`featureDev: Failed to prepare repo: ${error}`)
if (error instanceof ToolkitError && error.code === 'ContentLengthError') {
if (options?.featureName === 'docGeneration') {
throw new DocContentLengthError()
}
throw new ContentLengthError()
}
throw new PrepareRepoFailedError()
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/amazonqDoc/session/sessionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export class DocPrepareCodeGenState extends BasePrepareCodeGenState {
return await prepareRepoData(workspaceRoots, workspaceFolders, span, {
...options,
isIncludeInfraDiagram: true,
featureName: 'docGeneration',
})
}
}

0 comments on commit bf8700f

Please sign in to comment.