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

aws-amplify/storage list() pagination pageSize error: No overload matches this call. #14099

Open
tomphan opened this issue Dec 21, 2024 · 5 comments
Assignees
Labels
pending-maintainer-response Issue is pending a response from the Amplify team. question General question Storage Related to Storage components/category transferred This issue was transferred from another Amplify project

Comments

@tomphan
Copy link

tomphan commented Dec 21, 2024

Environment information

System:
  OS: Windows 10 10.0.19045
  CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
  Memory: 3.60 GB / 15.89 GB
Binaries:
  Node: 22.9.0 - C:\Program Files\nodejs\node.EXE       
  Yarn: 1.22.22 - ~\AppData\Roaming\npm\yarn.CMD        
  npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/auth-construct: 1.3.1
  @aws-amplify/backend: 1.5.0
  @aws-amplify/backend-auth: 1.2.0
  @aws-amplify/backend-cli: 1.2.9
  @aws-amplify/backend-data: 1.1.4
  @aws-amplify/backend-deployer: 1.1.5
  @aws-amplify/backend-function: 1.7.0
  @aws-amplify/backend-output-schemas: 1.3.0
  @aws-amplify/backend-output-storage: 1.1.2
  @aws-amplify/backend-secret: 1.1.4
  @aws-amplify/backend-storage: 1.2.1
  @aws-amplify/cli-core: 1.1.3
  @aws-amplify/client-config: 1.4.0
  @aws-amplify/deployed-backend-client: 1.4.2
  @aws-amplify/form-generator: 1.0.3
  @aws-amplify/model-generator: 1.0.8
  @aws-amplify/platform-core: 1.1.0
  @aws-amplify/plugin-types: 1.3.0
  @aws-amplify/sandbox: 1.2.3
  @aws-amplify/schema-generator: 1.2.4
  aws-amplify: 6.10.3
  aws-cdk: 2.163.1
  aws-cdk-lib: 2.163.1
  typescript: 5.6.3
AWS environment variables:
  AWS_DEFAULT_REGION = us-west-1
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
  AWS_STS_REGIONAL_ENDPOINTS = regional
No CDK environment variables

Describe the bug

Trying implementing storage list() following the doc. The simple list without pagination works well.

        const response = await list({
            path: 'guest/pdf/',
        });

However, with pagination, the compiler complains:

        const response = await list({
            path: 'guest/pdf/',
            pageSize: PAGE_SIZE,
            nextToken: nextToken,
        });

error TS2769: No overload matches this call.
The last overload gave the following error.
Object literal may only specify known properties, and 'path' does not exist in type 'ListAllInput'.

xx path: 'guest/pdf/',
~~~~

Please take a look. Thanks.

Reproduction steps

Simple implementation of listing a storage following the doc.

@tomphan tomphan added the pending-triage Issue is pending triage label Dec 21, 2024
@ykethan
Copy link
Member

ykethan commented Dec 23, 2024

Hey,👋 thanks for raising this! I'm going to transfer this over to our JS repository for better assistance 🙂

@ykethan ykethan transferred this issue from aws-amplify/amplify-backend Dec 23, 2024
@ykethan ykethan added transferred This issue was transferred from another Amplify project Gen 2 Issues related to Gen 2 Amplify projects labels Dec 23, 2024
@github-actions github-actions bot added the pending-maintainer-response Issue is pending a response from the Amplify team. label Dec 23, 2024
@cwomack cwomack self-assigned this Dec 23, 2024
@cwomack cwomack added Storage Related to Storage components/category question General question and removed Gen 2 Issues related to Gen 2 Amplify projects pending-triage Issue is pending triage labels Dec 23, 2024
@cwomack
Copy link
Member

cwomack commented Dec 23, 2024

Hey, @tomphan 👋. Can you share the frontend code that's being used to make the list() call as well as the docs you were referencing for this (I'm guess it was this page, but want to be sure)? And what do you have set for the PAGE_SIZE variable as well?

@cwomack cwomack added pending-community-response Issue is pending a response from the author or community. and removed pending-maintainer-response Issue is pending a response from the Amplify team. labels Dec 23, 2024
@tomphan
Copy link
Author

tomphan commented Dec 30, 2024

Hi. I did not get notification from github about all your replies, in my Inbox, don't know why, even being mentioned, so I come back late.

The full implementing code, that currently causing compile error:

import { list } from "aws-amplify/storage";
import { useEffect } from "react";

export default function Test() {
        
    const fetchFiles = async () => {

        const PAGE_SIZE = 20;
        let nextToken = undefined;

        const response = await list({
            path: 'a/b/c',
            pageSize: PAGE_SIZE,
            nextToken: nextToken,            
        });
        
        if (response.nextToken) {
            nextToken = response.nextToken;
        } else {
            nextToken = undefined;
        }
    }

    useEffect(() => {
        
        fetchFiles();
        
    }, []);

    return (<></>);
}

Note: I'm using Vite for React based from the sample template got from Quickstart doc amplify-vite-react-template.

The error appears in both tsLinter and from tsc compiling.

IDE tslint message, in VSCode IDE, when hover over the underline marked word path:

No overload matches this call.
The last overload gave the following error.
Object literal may only specify known properties, and 'path' does not exist in type 'ListAllInput'.ts(2769)
list.d.ts(39, 25): The last overload is declared here.
(property) StorageOperationInputWithPath.path: string | (({ identityId }: {
identityId?: string;
}) => string)

tsc compiler message:

npm run build

[email protected] build
tsc && vite build

src/test.tsx:12:13 - error TS2769: No overload matches this call.
The last overload gave the following error.
Object literal may only specify known properties, and 'path' does not exist in type 'ListAllInput'.

12 path: 'a/b/c',
~~~~

The doc refering for this is exact the page refered: https://docs.amplify.aws/react/build-a-backend/storage/list-files/#list-files

@github-actions github-actions bot added pending-maintainer-response Issue is pending a response from the Amplify team. and removed pending-community-response Issue is pending a response from the author or community. labels Dec 30, 2024
@HuiSF
Copy link
Member

HuiSF commented Dec 30, 2024

Hey @tomphan thanks for following up.

Looking at the sample code you provided above, the pageSize and nextToken should be options parameters. You should call the list API as the following:

const PAGE_SIZE = 20;
let nextToken = undefined;

const response = await list({
    path: 'a/b/c',
    options: {
      pageSize: PAGE_SIZE,
      nextToken,
    }
});

The TS complained error was specifically complaining about passing wrong parameters.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Dec 30, 2024
@tomphan
Copy link
Author

tomphan commented Dec 31, 2024

Thanks, so the wrong params was taken from the doc, on the link refered above. Please correct the doc.

@github-actions github-actions bot added the pending-maintainer-response Issue is pending a response from the Amplify team. label Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-maintainer-response Issue is pending a response from the Amplify team. question General question Storage Related to Storage components/category transferred This issue was transferred from another Amplify project
Projects
None yet
Development

No branches or pull requests

4 participants