Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Tried to cast node with kind JS_STRING_LITERAL_EXPRESSION as AnyJsxAttributeValue #4639

Closed
1 task done
fubhy opened this issue Jun 30, 2023 · 10 comments · Fixed by #4662
Closed
1 task done

Tried to cast node with kind JS_STRING_LITERAL_EXPRESSION as AnyJsxAttributeValue #4639

fubhy opened this issue Jun 30, 2023 · 10 comments · Fixed by #4662
Labels
A-Linter Area: linter S-Bug: confirmed Status: report has been confirmed as a valid bug

Comments

@fubhy
Copy link

fubhy commented Jun 30, 2023

Environment information

CLI:
  Version:                      12.1.3-nightly.af25635
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  ROME_LOG_DIR:                 unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.2.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "pnpm/8.6.1"

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

Workspace:
  Open Documents:               0

Discovering running Rome servers...

Incompatible Rome Server: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Rage discovered this running server using an incompatible version of Rome.

Server:
  Version:                      12.1.3

What happened?

Rome encountered an unexpected error

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

Source Location: /home/runner/work/tools/tools/crates/rome_rowan/src/ast/mod.rs:228:13
Thread Name: rome::worker_5
Message: Tried to cast node with kind JS_STRING_LITERAL_EXPRESSION as `"rome_js_syntax::generated::nodes::AnyJsxAttributeValue"` but was unable to cast

Expected result

It shouldn't throw ;-)

Btw. it would be easier to debug if the error included the name of the file.

Code of Conduct

  • I agree to follow Rome's Code of Conduct
@fubhy fubhy added the S-To triage Status: user report of a possible bug that needs to be triaged label Jun 30, 2023
@ematipico
Copy link
Contributor

@fubhy could you please replicate the issue and share it with us? We can't really help you without a way to understand how you triggered the issue

@ematipico ematipico added the S-Needs info Status: the issue needs more info in order to be triaged label Jun 30, 2023
@fubhy
Copy link
Author

fubhy commented Jun 30, 2023

The project I am in has thousands of files. I have no idea which file is causing this and it would take quite some time to narrow it down manually. Is there a way for rome to output the name of the file it blew up on?

@Conaclos
Copy link
Contributor

@fubhy
You could use the find unix command to excute rome check on every file individually:

find src -name '*.ts' -exec npx rome check {} \;

@ematipico
Copy link
Contributor

If it can help, that error is likely coming from a JSX file.

@fubhy
Copy link
Author

fubhy commented Jun 30, 2023

Will do that on monday and report back. Thanks!

@fubhy
Copy link
Author

fubhy commented Jul 1, 2023

Found the culprit ... This JSX code triggers the exception:

return  <MyComponent label={<>Some label in a fragment</>} />

Now... Why this was written in this way, I don't know. And it's not necessary, so I removed it. But it's technically valid code so shouldn't throw imho.

@ematipico
Copy link
Contributor

How did you trigger the error? That's an information you missed in the original description. The playground doesn't trigger any issue

@fubhy
Copy link
Author

fubhy commented Jul 2, 2023

How did you trigger the error? That's an information you missed in the original description. The playground doesn't trigger any issue

I can't trigger it in the playground either. But it consistently errors out when running the cli with rome check --apply-unsafe.

@ematipico
Copy link
Contributor

Then it's probably triggered by some lint rule with a code action that emits an invalid AST, and this AST gets passed to some other rule, and it blows. Having a repro will surely help us!

@fubhy
Copy link
Author

fubhy commented Jul 2, 2023

Then it's probably triggered by some lint rule with a code action that emits an invalid AST, and this AST gets passed to some other rule, and it blows. Having a repro will surely help us!

The repro is basically just running rome check --apply-unsafe on any file that has a redundant JSX fragment in a prop.

But np, here it is: https://github.com/fubhy/rome-bug-repro

@ematipico ematipico added S-Bug: confirmed Status: report has been confirmed as a valid bug A-Linter Area: linter and removed S-To triage Status: user report of a possible bug that needs to be triaged S-Needs info Status: the issue needs more info in order to be triaged labels Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Linter Area: linter S-Bug: confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants