-
Notifications
You must be signed in to change notification settings - Fork 761
fix: allow inference profile application when uploading file #1323
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
fix: allow inference profile application when uploading file #1323
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code correctly implements inference profile support with proper ARN handling and model extraction logic.
if (awsBedrockModel.includes('arn:aws')) { | ||
const foundationModel = awsBedrockModel.includes('foundation-model/') | ||
? awsBedrockModel.split('/').pop() | ||
: await getFoundationModelFromInferenceProfile( | ||
c, | ||
awsBedrockModel, | ||
providerOptions | ||
); | ||
if (foundationModel) { | ||
awsBedrockModel = foundationModel; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Bug Fix
Issue: Logic error in ARN parsing - split('/').pop()
will return undefined for ARNs ending with '/' or empty segments
Fix: Add null check and fallback handling for edge cases
Impact: Prevents runtime crashes when processing malformed ARNs
if (awsBedrockModel.includes('arn:aws')) { | |
const foundationModel = awsBedrockModel.includes('foundation-model/') | |
? awsBedrockModel.split('/').pop() | |
: await getFoundationModelFromInferenceProfile( | |
c, | |
awsBedrockModel, | |
providerOptions | |
); | |
if (foundationModel) { | |
awsBedrockModel = foundationModel; | |
} | |
} | |
if (awsBedrockModel.includes('arn:aws')) { | |
const foundationModel = awsBedrockModel.includes('foundation-model/') | |
? awsBedrockModel.split('/').pop() || awsBedrockModel | |
: await getFoundationModelFromInferenceProfile( | |
c, | |
awsBedrockModel, | |
providerOptions | |
); | |
if (foundationModel) { | |
awsBedrockModel = foundationModel; | |
} | |
} |
const { | ||
awsRegion, | ||
awsS3Bucket, | ||
awsBedrockModel: modelParam, | ||
} = providerOptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Code Refactor
Issue: Inconsistent variable naming - modelParam
is used temporarily but awsBedrockModel
is the actual working variable
Fix: Use more descriptive names to clarify the transformation flow
Impact: Improves code readability and reduces confusion about variable purpose
const { | |
awsRegion, | |
awsS3Bucket, | |
awsBedrockModel: modelParam, | |
} = providerOptions; | |
const { | |
awsRegion, | |
awsS3Bucket, | |
awsBedrockModel: originalModelParam, | |
} = providerOptions; |
providerOptions.awsS3ObjectKey || crypto.randomUUID() + '.jsonl'; | ||
|
||
if (!awsS3Bucket || !awsBedrockModel) { | ||
if (!awsS3Bucket || !modelParam) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Code Refactor
Issue: Variable reference should match the renamed parameter for consistency
Fix: Update validation to use the renamed parameter
Impact: Maintains consistency with variable naming convention
if (!awsS3Bucket || !modelParam) { | |
if (!awsS3Bucket || !originalModelParam) { |
); | ||
} | ||
|
||
let awsBedrockModel = modelParam; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Code Refactor
Issue: Variable initialization should reference the renamed parameter for consistency
Fix: Update initialization to use the renamed parameter
Impact: Maintains consistency with variable naming convention
let awsBedrockModel = modelParam; | |
let awsBedrockModel = originalModelParam; |
Description
Motivation
Type of Change
How Has This Been Tested?
Screenshots (if applicable)
Checklist
Related Issues