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

🐛 GraphQL byte index out of bounds #4101

Closed
1 task done
DanielEscorciaOrtiz opened this issue Sep 26, 2024 · 4 comments
Closed
1 task done

🐛 GraphQL byte index out of bounds #4101

DanielEscorciaOrtiz opened this issue Sep 26, 2024 · 4 comments
Labels
A-Formatter Area: formatter L-GraphQL Language GraphQL S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@DanielEscorciaOrtiz
Copy link

Environment information

CLI:
  Version:                      1.9.2
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.17.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/10.8.2"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 false

Workspace:
  Open Documents:               0

What happened?

With this config:

{
  "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
  "files": {
    "ignoreUnknown": true
  },
  "formatter": {
    "enabled": true,
    "formatWithErrors": false,
    "indentStyle": "space",
    "indentWidth": 2,
    "lineEnding": "lf",
    "lineWidth": 100,
    "bracketSpacing": true
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true
    }
  },
  "vcs": {
    "enabled": true,
    "clientKind": "git",
    "useIgnoreFile": true,
    "defaultBranch": "main"
  }
}

And this GraphQL file

type Biome {
    """
    Some text with `backticks` on it

    @someJsDocFlag
    """
    field: Boolean!
}

Running this command

biome check biome.graphql

Reports issue

Biome encountered an unexpected error

This is a bug in Biome, not an error in your code, and we would appreciate it if you could report it to https://github.com/biomejs/biome/issues/ along with the following information to help us fixing the issue:

Source Location: crates/biome_graphql_formatter/src/graphql/value/string_value.rs:45:51
Thread Name: biome::worker_1
Message: byte index 4 is out of bounds of ``

biome.graphql internalError/panic  INTERNAL  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ processing panicked: byte index 4 is out of bounds of ``
  
  ⚠ This diagnostic was derived from an internal Biome error. Potential bug, please report it if necessary.
  

Checked 0 files in 6ms. No fixes applied.
internalError/io ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ No files were processed in the specified paths.

Expected result

It should support the format correctly

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@ematipico
Copy link
Member

cc @vohoanglong0107

@Conaclos Conaclos added S-Bug-confirmed Status: report has been confirmed as a valid bug L-GraphQL Language GraphQL A-Formatter Area: formatter labels Sep 28, 2024
@vohoanglong0107
Copy link
Contributor

This issue was fixed in the nightly build. Could you please try and check if that's the case?

@ematipico
Copy link
Member

Duplicate of #3924

@ematipico ematipico marked this as a duplicate of #3924 Oct 1, 2024
@ematipico ematipico closed this as not planned Won't fix, can't repro, duplicate, stale Oct 1, 2024
@DanielEscorciaOrtiz
Copy link
Author

Just checked with @biomejs/biome": "1.9.3

CLI:
  Version:                      1.9.3
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.17.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/10.8.2"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 false

Workspace:
  Open Documents:               0

And using same setup, the command biome check biome.graphql returns

biome.graphql format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ Formatter would have printed the following content:
  
    1 1 │   type Biome {
    2   │ - ····"""
    3   │ - ····Some·text·with·`backticks`·on·it
      2 │ + ··"""
      3 │ + ··Some·text·with·`backticks`·on·it
    4 4 │   
    5   │ - ····@someJsDocFlag
    6   │ - ····"""
    7   │ - ····field:·Boolean!
    8   │ - }
      5 │ + ··@someJsDocFlag
      6 │ + ··"""
      7 │ + ··field:·Boolean!
      8 │ + }
      9 │ + 
  

Checked 1 file in 559µs. No fixes applied.
Found 1 error.
check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ Some errors were emitted while running checks.

So I think it is working as expected

Thank you for your great effort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Formatter Area: formatter L-GraphQL Language GraphQL S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

No branches or pull requests

4 participants