-
Notifications
You must be signed in to change notification settings - Fork 584
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
Inconsistent responses from CreateCollectionCommand and DescribeCollectionCommand #6704
Comments
Hey @jeffayers31 Thanks for the feedback! I can reproduce this issue. import { RekognitionClient, CreateCollectionCommand, DescribeCollectionCommand } from "@aws-sdk/client-rekognition";
import { fromIni } from '@aws-sdk/credential-providers';
// Configure the Rekognition client
const rekognitionClient = new RekognitionClient({
region: "us-east-1", // Replace with your region
credentials: fromIni({ profile: 'default' }) // Use your AWS profile
});
// Collection name to be created and described
const collectionName = "my-face-collection";
// Function to create a collection
async function createCollection(collectionId) {
try {
console.log(`Creating collection: ${collectionId}`);
const command = new CreateCollectionCommand({
CollectionId: collectionId
});
const response = await rekognitionClient.send(command);
console.log("Collection created successfully:");
console.log("Collection ARN:", response.CollectionArn);
return response;
} catch (error) {
console.error("Error creating collection:", error);
throw error;
}
}
// Function to describe a collection
async function describeCollection(collectionId) {
try {
console.log(`Describing collection: ${collectionId}`);
const command = new DescribeCollectionCommand({
CollectionId: collectionId
});
const response = await rekognitionClient.send(command);
console.log("Collection details:");
console.log("Collection ARN:", response.CollectionArn);
return response;
} catch (error) {
console.error("Error describing collection:", error);
throw error;
}
}
// Main function to demonstrate usage
async function main() {
try {
// Create the collection
console.log("Step 1: Creating Collection");
await createCollection(collectionName);
// returns aws:rekognition:us-east-1:XXX:collection/my-face-collection
// Wait for a moment to ensure the collection is created
console.log("\nWaiting for collection to be fully created...");
await new Promise(resolve => setTimeout(resolve, 2000));
// Describe the collection
console.log("\nStep 2: Describing Collection");
const res = await describeCollection(collectionName);
console.log("res: ", res);
//returns - arn:aws:rekognition:us-east-1:XXX:collection/my-face-collection
} catch (error) {
console.error("Main function error:", error);
}
}
// Execute the main function
main(); In |
It seems that the service team generates two sets of arn - I will cut a ticket to the service team. Thanks! |
internal ref - V1601989251 |
Checkboxes for prior research
Describe the bug
I'm using AWS SDK v3, and specifically, "@aws-sdk/client-rekognition": "^3.699.0". I'm trying out AWS Rekognition, and during my testing I'm getting inconsistent responses from CreateCollectionCommand and DescribeCollectionCommand functions from AWS SDK v3. CreateCollectionCommand response returns a CollectionArn (Arn is capitalized) field while DescribeCollectionCommand returns CollectionARN (Arn is all caps) field, and their values are slightly different. CreateCollectionCommand returns a value in CollectionArn that starts with 'arn:' at the beginning while DescribeCollectionCommand returns a value in CollectionARN without the 'arn:'.
I'm using Vitest testing framework for my Typescript, and when I run both commands and compare the results, I get an error:
expect(createResponse.CollectionARN).toBe(getResponse.CollectionARN);
But, even if I change it to:
expect(createResponse.CollectionArn).toBe(getResponse.CollectionARN);
It still fails because the values are inconsistent.
Expected: "arn:aws:rekognition:us-east-1:************:collection/rm-test-collection"
Received: "aws:rekognition:us-east-1:************collection/rm-test-collection"
Regression Issue
SDK version number
@aws-sdk/client-rekognition@3.699.0
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v20.12.2
Reproduction Steps
Observed Behavior
FAIL source/tests/unit/Rekognition-real.test.ts > RekognitionService Real Images > man.jpg is not in a collection testing > 4. createCollection response should equal getCollection response
AssertionError: expected 'aws:rekognition:us-east-1:*…' to be 'arn:aws:rekognition:us-east-1:…' // Object.is equality
Expected: "arn:aws:rekognition:us-east-1::collection/rm-test-collection"
Received: "aws:rekognition:us-east-1::collection/rm-test-collection"
❯ source/tests/unit/Rekognition-real.test.ts:51:50
49| const getResponse = await rekognitionService.getCollection(collec…
50| expect(getResponse).toBeDefined();
51| expect(createResponse.CollectionArn).toBe(getResponse.CollectionA…
| ^
52| });
Expected Behavior
I would expect that there is consistency in the field names and field values. Either return 'CollectionArn' or 'CollectionARN' from both calls and make sure the values returned are identical.
Possible Solution
I'm not sure if AWS enforces consistency between libraries, but within the same library, calls should be consistent. Please make them consistent.
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: