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

Unhandled error for GraphQL query #3087

Closed
readeral opened this issue Oct 30, 2024 · 4 comments
Closed

Unhandled error for GraphQL query #3087

readeral opened this issue Oct 30, 2024 · 4 comments
Labels
investigating We're actively investigating this issue validated Version information for this issue has been validated

Comments

@readeral
Copy link

readeral commented Oct 30, 2024

Summary

When trying to deploy a LWC that uses lightning/uiGraphQLApi, if the query template-literal misuses an alias for an id field (for example masterId: Id) the error returned is unhandled and so a generic error for deployment failure is listed:

Index 1 out of bounds for length 1

This would send a developer looking for a poorly referenced array in their component, but in this case the missing array is within the cli toolchain.

Steps To Reproduce

IMPORTANT
Provide a repository that's configured to reproduce the issue. If you are unable to provide a repo, please explain why not. The more info we have from the start, the faster we can resolve your issue.
We may close your issue if you don't include proper instructions.

  • Generate a project with sf project generate or fork dreamhouse-lwc.
  • Provide detailed step-by-step instructions on how to reproduce the issue.

Use https://github.com/trailheadapps/lwc-recipes/tree/main/force-app/main/default/lwc/graphqlContacts, and edit the graphQl query to include an alias for the Id field:

node {
  contactId: Id <<----- illegal alias
  Name {
     value
  }
  Phone {
     value
  }
  Picture__c: Picture__c {
     value
  }
  Title {
    value
  }
}

Deploying will fail.

Expected result

Error should return in keeping with existing graphql query errors (e.g. for Invalid syntax or FieldUndefined validation error) such as:
Illegal use of alias for Id field or similar

Actual result

Deployment fails with generic deployment error Index 1 out of bounds for length 1

Additional information

Obviously using an alias for the Id field is an anti-pattern, and the documentation only encourages the use of aliases with custom fields, but the mistake is very difficult to pick up when other standard fields can be aliased without trouble and other malformed query strings have specific errors.

System Information

{
  "architecture": "darwin-arm64",
  "cliVersion": "@salesforce/cli/2.63.9",
  "nodeVersion": "node-v20.16.0",
  "osVersion": "Darwin 24.1.0",
  "rootPath": "/Users/alan/.nvm/versions/node/v20.16.0/lib/node_modules/@salesforce/cli",
  "shell": "zsh",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.6 (core)",
    "@oclif/plugin-commands 4.1.3 (core)",
    "@oclif/plugin-help 6.2.15 (core)",
    "@oclif/plugin-not-found 3.2.22 (core)",
    "@oclif/plugin-plugins 5.4.15 (core)",
    "@oclif/plugin-search 1.2.12 (core)",
    "@oclif/plugin-update 4.6.4 (core)",
    "@oclif/plugin-version 2.2.15 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.19 (core)",
    "@oclif/plugin-which 3.2.16 (core)",
    "@salesforce/cli 2.63.9 (core)",
    "apex 3.5.4 (core)",
    "api 1.3.1 (core)",
    "auth 3.6.68 (core)",
    "data 3.7.1 (core)",
    "deploy-retrieve 3.13.1 (core)",
    "info 3.4.12 (core)",
    "lightning-dev 1.3.0 (user) published 39 days ago (Sat Sep 21 2024) (latest is 1.9.0)",
    "limits 3.3.33 (core)",
    "marketplace 1.2.26 (core)",
    "org 4.7.0 (core)",
    "packaging 2.8.12 (user) published 17 days ago (Sat Oct 12 2024)",
    "schema 3.3.36 (core)",
    "settings 2.3.24 (core)",
    "signups 2.3.10 (user) published 142 days ago (Sun Jun 09 2024) (latest is 2.5.23)",
    "sobject 1.4.42 (core)",
    "source 3.5.21 (core)",
    "telemetry 3.6.16 (core)",
    "templates 56.3.24 (core)",
    "trust 3.7.34 (core)",
    "user 3.5.33 (core)",
    "@salesforce/sfdx-scanner 4.4.0 (user) published 91 days ago (Wed Jul 31 2024) (latest is 4.7.0)",
    "sfdmu 4.36.7 (user) published 0 days ago (Wed Oct 30 2024)",
    "sfdx-essentials 2.12.0 (user) published 1050 days ago (Wed Dec 15 2021)",
    "sfdx-git-delta 5.49.0 (user) published 10 days ago (Sat Oct 19 2024)",
    "sfdx-hardis 5.3.0 (user) published 5 days ago (Fri Oct 25 2024)",
    "texei-sfdx-plugin 2.8.1 (user) published 8 days ago (Mon Oct 21 2024)"
  ]
}
@readeral readeral added the investigating We're actively investigating this issue label Oct 30, 2024
Copy link

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

Copy link

Hello @readeral 👋 It looks like you didn't include the full Salesforce CLI version information in your issue.
Please provide the output of version --verbose --json for the CLI you're using (sf or sfdx).

A few more things to check:

  • Make sure you've provided detailed steps to reproduce your issue.
    • A repository that clearly demonstrates the bug is ideal.
  • Make sure you've installed the latest version of Salesforce CLI. (docs)
    • Better yet, try the rc or nightly versions. (docs)
  • Try running the doctor command to diagnose common issues.
  • Search GitHub for existing related issues.

Thank you!

@github-actions github-actions bot added more information required Issue requires more information or a response from the customer investigating We're actively investigating this issue validated Version information for this issue has been validated and removed investigating We're actively investigating this issue more information required Issue requires more information or a response from the customer labels Oct 30, 2024
@cristiand391
Copy link
Member

hey, I agree with your suggestion but unfortunately that error comes from the metadata API (component failures), the CLI only prints render them in the failures table.

The Metadata API team doesn't take requests from GH.

@readeral
Copy link
Author

readeral commented Oct 31, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigating We're actively investigating this issue validated Version information for this issue has been validated
Projects
None yet
Development

No branches or pull requests

2 participants