Skip to content
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

Invoking ChatSession.getTranscript() without arguments fails even though all arguments are optional #128

Closed
marcogrcr opened this issue Feb 24, 2023 · 0 comments
Assignees

Comments

@marcogrcr
Copy link
Contributor

ChatSession.getTranscript() must always be invoked with an Object argument, even though all arguments are optional:

const session = connect.ChatSession.create({ /* (...) */});

// specifying an empty object (i.e. `{}`) is required, even though all arguments are optional
const transcript = await session.getTranscript({});

Ideally, this method should be allowed to be invoked without any arguments to achieve the same purpose:

const session = connect.ChatSession.create({ /* (...) */});

// this should be allowed, yet this is thrown instead:
// Uncaught TypeError: Cannot read properties of undefined (reading 'metadata')
const transcript = await session.getTranscript();

This happens because the inputArgs parameter of ChatController.prototype.getTranscript() is used without any validation:

getTranscript(inputArgs) {
const startTime = new Date().getTime();
const metadata = inputArgs.metadata || null;

Proposed fix:

Update ChatController.prototype.getTranscript() to make inputArgs optional with {} as the default value:

getTranscript(inputArgs = {}) {
  // (...)
}
@spencerlepine spencerlepine added the ⌛️ In Progress Team is currently working on fix label Mar 15, 2023
@spencerlepine spencerlepine added 🗒️ In Backlog Reviewed by team, added to backlog and removed ⌛️ In Progress Team is currently working on fix labels May 19, 2023
@spencerlepine spencerlepine added ⌛️ In Progress Team is currently working on fix and removed 🗒️ In Backlog Reviewed by team, added to backlog labels Oct 2, 2023
@spenlep-amzn spenlep-amzn removed the ⌛️ In Progress Team is currently working on fix label Dec 22, 2023
@spenlep-amzn spenlep-amzn self-assigned this Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants