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

indexQueryFactory tries to run Object.keys(null) what causes error #13941

Closed
3 tasks done
WojciechKasprzyk opened this issue Oct 21, 2024 · 13 comments
Closed
3 tasks done
Assignees
Labels
Gen 2 Issues related to Gen 2 Amplify projects GraphQL Related to GraphQL API issues to-be-reproduced Used in order for Amplify to reproduce said issue

Comments

@WojciechKasprzyk
Copy link

Before opening, please confirm:

JavaScript Framework

Angular

Amplify APIs

GraphQL API

Amplify Version

v6

Amplify Categories

api

Backend

Amplify Gen 2

Environment information

  System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 101.64 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.2.0 - /usr/local/bin/node
    npm: 10.7.0 - /usr/local/bin/npm
    bun: 1.0.0 - ~/.bun/bin/bun
  Browsers:
    Chrome: 129.0.6668.101
    Safari: 17.6
    Safari Technology Preview: 18.0
  npmPackages:
    @angular-devkit/build-angular: ^18.2.1 => 18.2.1 
    @angular-slider/ngx-slider: 18.0.0 => 18.0.0 
    @angular/animations: ^18.2.1 => 18.2.1 
    @angular/cli: ^18.2.1 => 18.2.1 
    @angular/common: ^18.2.1 => 18.2.1 
    @angular/compiler: ^18.2.1 => 18.2.1 
    @angular/compiler-cli: ^18.2.1 => 18.2.1 
    @angular/core: ^18.2.1 => 18.2.1 
    @angular/forms: ^18.2.1 => 18.2.1 
    @angular/platform-browser: ^18.2.1 => 18.2.1 
    @angular/platform-browser-dynamic: ^18.2.1 => 18.2.1 
    @angular/router: ^18.2.1 => 18.2.1 
    @aws-amplify/backend: ^1.1.1 => 1.1.1 
    @aws-amplify/backend-cli: ^1.2.5 => 1.2.5 
    @aws-amplify/ui-angular: ^5.0.19 => 5.0.28 
    @ngrx/effects: ^18.0.2 => 18.0.2 
    @ngrx/entity: ^18.0.2 => 18.0.2 
    @ngrx/eslint-plugin: ^18.0.2 => 18.0.2 
    @ngrx/operators: ^18.0.2 => 18.0.2 (18.0.1)
    @ngrx/schematics: ^18.0.2 => 18.0.2 
    @ngrx/store: ^18.0.2 => 18.0.2 
    @ngrx/store-devtools: ^18.0.2 => 18.0.2 
    @types/jasmine: ~5.1.4 => 5.1.4 
    aws-amplify: ^6.6.3 => 6.6.3 
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/enable-oauth-listener:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/data:  undefined ()
    aws-amplify/data/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
    bootstrap: ^5.3.3 => 5.3.3 
    jasmine-core: ~5.2.0 => 5.2.0 (4.6.1)
    karma: ~6.4.4 => 6.4.4 
    karma-chrome-launcher: ~3.2.0 => 3.2.0 
    karma-coverage: ~2.2.1 => 2.2.1 
    karma-coverage-coffee-example:  1.0.0 
    karma-jasmine: ~5.1.0 => 5.1.0 
    karma-jasmine-html-reporter: ~2.1.0 => 2.1.0 
    ngx-toastr: ^19.0.0 => 19.0.0 
    rxjs: ~7.8.1 => 7.8.1 
    rxjs/ajax:  undefined ()
    rxjs/fetch:  undefined ()
    rxjs/operators:  undefined ()
    rxjs/testing:  undefined ()
    rxjs/webSocket:  undefined ()
    swiper: ^10.3.1 => 10.3.1 
    tslib: ^2.7.0 => 2.7.0 (2.6.3, 2.0.3, 2.4.1, 2.2.0, 2.3.1, 1.14.1)
    typescript: ~5.5.4 => 5.5.4 (4.4.4, 4.9.5)
    zone.js: ~0.14.10 => 0.14.10 
  npmGlobalPackages:
    @angular/cli: 18.2.6
    @aws-amplify/cli: 12.12.4
    @ionic/cli: 7.2.0
    cordova-res: 0.15.4
    cordova: 12.0.0
    corepack: 0.28.1
    jest: 29.7.0
    n: 9.2.3
    npm: 10.7.0
    ts-node: 10.9.2


Describe the bug

If API return data equals null then indexQueryFactory tries to run Object.keys(null) which causes error. It's funny that you mentioned in the comment that data can be null and you mentioned that you check it but actually, it is not.

image

null !== undefined so Object.keys is called with invalid argument.

Expected behavior

There should be a condition like data != null to check both null and undefined.

Reproduction steps

Call API that returns data: null

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending a response from the Amplify team. labels Oct 21, 2024
@WojciechKasprzyk
Copy link
Author

@chachasammy is it a scam? @aws-amplify-ops Could you ban it?

@chrisbonifacio chrisbonifacio self-assigned this Oct 21, 2024
@aws-amplify aws-amplify deleted a comment Oct 21, 2024
@stocaaro
Copy link
Member

@WojciechKasprzyk Thanks for calling that out! Deleted/reported.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Oct 21, 2024
@chrisbonifacio
Copy link
Member

Hi @WojciechKasprzyk 👋 thanks for raising this issue and we've taken action against the comment you pointed out.

Regarding this issue, we will reproduce with the conditions you mentioned and look into addressing it

@stocaaro stocaaro added the pending-maintainer-response Issue is pending a response from the Amplify team. label Oct 21, 2024
@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Oct 21, 2024
@chrisbonifacio chrisbonifacio added GraphQL Related to GraphQL API issues to-be-reproduced Used in order for Amplify to reproduce said issue Gen 2 Issues related to Gen 2 Amplify projects and removed pending-triage Issue is pending triage labels Oct 21, 2024
@chrisbonifacio
Copy link
Member

Hi @WojciechKasprzyk just curious, could you share the server code that is returning potentially null values? I'm curious if this is caused by an auto-generated query/mutation of ours or if it is custom business logic in a custom query/mutation.

@chrisbonifacio chrisbonifacio added the pending-community-response Issue is pending a response from the author or community. label Oct 23, 2024
@WojciechKasprzyk
Copy link
Author

Hi @chrisbonifacio Unfortunately I cannot, but as far as I know there is a model issue the causes API error an then responses null data.
Anyway, what does it change? The code should be prepared for null as it is described in comment 😄

@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 Oct 23, 2024
@chrisbonifacio
Copy link
Member

chrisbonifacio commented Oct 23, 2024

@WojciechKasprzyk I'm trying to figure out how to reproduce the behavior so we can address it but I can't think of a scenario where a null might be in the response. Is the shape of the response an array of items and some null values in the array? Or is the server returning only null?

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Oct 23, 2024
@WojciechKasprzyk
Copy link
Author

This is the response I get
image

@github-actions github-actions bot added the pending-maintainer-response Issue is pending a response from the Amplify team. label Oct 23, 2024
@chrisbonifacio
Copy link
Member

oh okay, I believe that particular error message means that the query is asking for fields that don't exist on the schema.

Can you confirm that parentGci and parentChannelID are defined as fields on the Category model?

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Oct 23, 2024
@WojciechKasprzyk
Copy link
Author

WojciechKasprzyk commented Oct 23, 2024

Yes, they are both type of id on the Category model

@github-actions github-actions bot added the pending-maintainer-response Issue is pending a response from the Amplify team. label Oct 23, 2024
@chrisbonifacio
Copy link
Member

Is that schema deployed and up to date in the AppSync console?

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Oct 23, 2024
@WojciechKasprzyk
Copy link
Author

it was not in sync, now there is no this error - I get different ehhh... 😄 But still the condition in amplify codebase is invalid

@github-actions github-actions bot added the pending-maintainer-response Issue is pending a response from the Amplify team. label Oct 23, 2024
@chrisbonifacio
Copy link
Member

We will look into the discrepancy in the codebase.

In the meantime, are you getting a different error now or are you unblocked at this time?

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Oct 23, 2024
@WojciechKasprzyk
Copy link
Author

Oh, I'm unblocked at this time, thank you very much @chrisbonifacio for helping me, I really appreciate 😄

@github-actions github-actions bot added the pending-maintainer-response Issue is pending a response from the Amplify team. label Oct 24, 2024
@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gen 2 Issues related to Gen 2 Amplify projects GraphQL Related to GraphQL API issues to-be-reproduced Used in order for Amplify to reproduce said issue
Projects
None yet
Development

No branches or pull requests

3 participants